- 0
[C++] Tutorial #1 Simple Sum/Average
Asked by
coolbunny1234,
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Yonah · Posted
I do not think you did cover all the scenarios. -
By zikalify · Posted
Is Polaroid's Now 3rd Gen camera worth the $99.99 price drop? by Paul Hill For at least a decade there has been a nostalgic feeling gripping people in response to the digitization of everything. We’ve seen this mainly in products like vinyl, and even apps like Slowly that make you wait before your friends receive your “letter”. Another such product trying to capitalize on nostalgia is the Polaroid Now 3rd Generation camera. For a limited time, you can pick it up for just $99.99, instead of $119.99. If you are still searching for a gift for Father’s Day, taking advantage of this limited-time deal would be our suggestion. The Polaroid Now 3rd Generation is available in several colors but only four - Black, Coral, Purple, and Yellow - are available for $99.99, and they all look great. While there is certainly nothing wrong with snapping photos on your phone and storing them in the cloud, you do lose out on the tactileness of a photograph that you get with the Polaroid Now 3rd Generation. Additionally, in recent years, Google has been nagging everyone that their Google Photos storage is about to run out, urging you to delete photos or pay to upgrade, in future clean ups, you might accidentally delete a photo you really wanted to keep, you can’t do that as easily with hard-copy photograph. What it does (and doesn’t) With the 3rd generation of Polaroid Now, you get several improvements over the predecessor. There is a better light meter, upgraded two-lens autofocus, a built-in tripod mount, photo filter compatibility, a self-timer to take snaps with yourself included, and double-exposure modes. This camera remains faithful to the iconic Polaroid design but comes with new colors, four of which are now $99.99 for a limited time. Environmentalism has become all the rage in recent years and consumers want stuff that’s produced more responsibly; to this end, Polaroid has used 40% recycled materials to reduce waste and improve the product’s carbon footprint. The Polaroid Now 3rd Generation uses Polaroid i-Type Film and 600 Film, both of which are sold separately. The cost of the film is probably the biggest issue with this product, it’s priced at $17.99 per 8-pack, so you’re definitely going to want to be mindful about the shots you take. You can cut the cost by buying in bulk. Some of the reviewers were also disappointed with the low-light shots they took indoors. If you are planning to take indoor shots, then be mindful about what other people have said. Outdoors, everything seems in order. The two-lens autofocus system mentioned earlier is a key new feature of this camera. The system combines two fixed focus zones with one lens covering distances from 0.40 meters to 1.3 meters, and the other covering from 1.0 meter to infinity. The camera then automatically switches lenses depending on the best one for the shot. With the self-timer, you can now set up the Polaroid Now 3rd Generation on a tripod and join in with a group photo, or just take a shot of yourself. The double exposure feature lets you layer two images on one piece of film to bring out your creativity to create visually striking and unexpected results. How it compares At this discounted price, the Polaroid Now 3rd Generation is the same price as the 2nd Generation model, but gets newer features. It should also be stated that there’s a Polaroid Now+ 3rd Generation which you can connect to your phone to control with an app, but it’s priced higher. If you’re just looking for a camera that doesn’t complicate things, then the Polaroid Now 3rd Generation is the ideal model. You get the new hardware features, but don’t need to worry about extra connectivity. Who it’s right for The Polaroid Now 3rd Generation is ideal for casual photographers, those looking to snap memories to tangible film, gift-givers looking to buy a parent a Father’s Day gift, or those who love the classic Polaroid aesthetic and want it on a shelf somewhere for decorative purposes. While the camera is now priced well at $99.99, buyers need to consider the on-going cost of the film, which can add up. For anyone who hasn’t used a film camera before, it’s also important for me to point out that prints take a bit of time to develop, some users have also complained about the low-light performance when indoors. If you’re looking for snapping retro outdoor shots, the Polaroid Now 3rd Generation is definitely worth your consideration! Polaroid Now 3rd Generation (Black): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Coral): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Purple): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Yellow): $99.99 (Amazon US) - MSRP $119.99 / 17% off This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases. -
By bikeman25 · Posted
My Machines with Classic Outlook 365, have a banner on top Next Time Outlook is opened, will be autoly switched to NEW Outlook, not sure if i should try to prevent that or just get used to new Outlook at this point Probably gonna try to prevent that now that i read that privacy notice -
By Eyevou · Posted
Yeah, no. I won't be "upgrading" to the "mandatory" Windows 11 until all the bugs with DirectX and Hibernate are sorted out. Until then ASUS and Microsoft can both stuff it where the sun don't shine. -
By Mockingbird · Posted
Microsoft Edge It works as expected, and I see no reason to use another browser.
-
-
Recent Achievements
-
m10d earned a badge
First Post
-
DarkShrunken earned a badge
Conversation Starter
-
jrromero17 earned a badge
One Month Later
-
jrromero17 earned a badge
Week One Done
-
johnwin1 earned a badge
Conversation Starter
-
-
Popular Contributors
-
Tell a friend
Question
coolbunny1234
As I do on most forums that I join, I usually post a series of tutorials for programming, specifically C++. I'll be creating tutorials at random or by request, and usually cover most of the basics, advancing into intermediate programming and later scratching the surface of more advanced programs.
This tutorial assumes you have basic, minimal knowledge of C++.
What you will need:
And that's it! I currently use Visual Studio 2013 Professional, I got it for free via Dreamspark (if you're a college student like myself, go grab it now) or download the evaluation software.
http://www.visualstudio.com/downloads/download-visual-studio-vs
Now for the tutorial! This program is a simple program that asks the user to specify the amount of grades you want averaged and summed. It then asks for the actual grade of each, followed by the logic of average/sum of the user specified grades.
Step 1
Open Visual Studio, and click File > New Project. A pop up window will appear, and on the left hand tab, select Visual C++, and then Win32 Console Application.
A screen will appear, click next, but do not click finish on the next screen!
Before clicking Finish, make sure you check off the box that says "Empty Project"
Next, Click the tab Project > Add New Item
A screen will appear like this one, chose the .cpp and name it whatever you'd like. This file is the source code file for your program.
You now have a blank workspace for your program, time to dive into the language.
Step 2
We're now going to add the file headers to the source. There are many functions and inputs in the language of C++, and these headers allow us access to them so we don't have to code them individually in each program. I.e the function "cout" , or command output, allows us to print whatever we want on screen.
So go ahead and add these file headers.
And here's an image for the visual learners of what it should be so far.
Step 3
After we add the headers, we need to initiate a start up function, and the default function that's called when a program is ran is int main(). Your entire source for your program, or the entire logic of the program, is within these parameters.
(I'll be adding code to previous code so it's chronological and makes more sense).
Boom! This is our entire program. Within those brackets, you can do whatever, such as say hello..
And if you ran this, it would create a program that says Hello Neowin. Simple, helloworld crap.
Step 4
However, we want to create a program that does averages/sums of user specified input. So how do we do that?
First, we're going to need to init and double a few variables.
The variables above are as follows:
Step 5
We now need to have the program ask the user how many grades are going to be inputted.
Let's break this down a little if you're lost. Currently, the code above simply is going to print out on screen "How many grades are you going to enter?", and n_grades will record whatever number you input.
Step 6
Now for the hardest part of the program. How are we going to code something that gives the user infinite amount of options (how many grades he can input... 1- infinity)? This is where the for loop comes in handy. I'm going to post the code first, then explain.
As you can see, the for loop above does it all for us. If you can't see however, read on. The first line of the loop
Simply inits the variable count, which we use to determine how many times we ask the user to enter a grade, based on his input before. Then, if count is less than or equal to n_grades, then we increment count by one, or count++.
Within the loop, we also take care of the math part of figuring out the sum of the grades, using
which is the same as
Step 7
The rest of the program is a cruise from this point on. We just need to to the math logic for the average, and output the results!! I'll post the full source below, as I've got to finish this up quickly.
And voila! We have a simple program that allows us to find the average and the sum of a user specified number. Sorry for the shortness and briefness of the tutorial, gotta run out the door as we speak. Let me know any areas that could be improved, tutorial wise or code wise. Thank you!
Link to comment
https://www.neowin.net/forum/topic/1207513-c-tutorial-1-simple-sumaverage/Share on other sites
13 answers to this question
Recommended Posts