- 0
[C++] Tutorial #1 Simple Sum/Average
Asked by
coolbunny1234,
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Copernic · Posted
Display Driver Uninstaller (DDU) 18.1.1.4 by Razvan Serea Display Driver Uninstaller (DDU) is a utility for completely removing AMD/NVIDIA/INTEL graphics drivers and related packages from your system, attempting to eliminate all leftovers (including registry entries, folders and files, driver store). Though AMD/NVIDIA/INTEL drivers can usually be removed via the Windows Control Panel, this uninstaller tool was created for situations where standard uninstall fails, or when you need to fully remove NVIDIA or ATI graphics card drivers. After using this driver cleaner, your system will behave as though it’s the first time you’re installing a new driver—similar to a fresh Windows installation. As with all such tools, we recommend creating a restore point beforehand, allowing you to undo changes if issues arise. If you're having trouble installing an older or newer driver, try it—there are reports that it resolves such problems. Recommended usage: The tool can be used in Normal mode but for absolute stability when using DDU, Safemode is always the best. Make a backup or a system restore (but it should normally be pretty safe). It is best to exclude the DDU folder completely from any security software to avoid issues. You do NOT need to uninstall the driver prior using DDU. Requirements: .NET Framework 4.8 Compatible with Windows 7, 8, 8.1, 10, and 11 (32-bit or 64-bit) Note: Using on Insider Preview builds is at your own risk. Display Driver Uninstaller (DDU) 18.1.1.4 changelog: Intel: Added NPU presence detection before removing shared DLL files (these were previously left to prevent potential NPU-related issues). Intel: Added optional NPU removal Improved "Extension" driver removal process. Updated several translations. Download: Display Driver Uninstaller 18.1.1.4 | 1.7 MB (Freeware) Download: DDU Portable | 1.2 MB Links: Display Driver Uninstaller Home Page | Screenshot | Forum Get alerted to all of our Software updates on Twitter at @NeowinSoftware -
By JayZJay · Posted
That is what I also think to a point. How is 26 necessarily different than just another iteration like 18, 19, 20, etc? At first I think it would be better for Apple to use 2026, 2027, and then maybe truncate it to just 28, 29, and so on. Granted, I also think it makes more sense to use the year when it was released (2025 or 25), not 26/2026. Maybe Apple's thinking is as stated by Aditya that the bulk of a release being the current release is during the following year (2026, for example) after it is released (2025, for example). There are other examples of these sorts of things. In the NBA, the season has always started in the Fall and ends in the Spring. When the season ends is how the season is named. So, this is the 2025 NBA season and the Pacers and Thunder are playing to be the 2025 NBA Champions. The NFL starts in the Fall and the end of the season is always in the beginning of the next year as well. The Super Bowl was played on February 9, 2025, but that was the end of the 2024 NFL season. So, contrary to the NBA, the NFL names it season based on when it starts, not when it ends. Maybe that is because more of the NFL season is played at the end of the year (2024 in the most recent example) whereas most of the NBA season is played in the first half of the following year (2025 in the current example). -
By M. Murcek · Posted
Years ago I was at COMDEX in Las Vegas and a pit boss told me all the casino hotel staff said of the geeks "They bring one clean shirt and a $10 bill and they don't change either one all week..." -
By leonsk29 · Posted
I really hate Capcom for cutting all that content on RE3 Remake. It could have been a masterpiece like 2 Remake was. -
By M. Murcek · Posted
Yes. Wouldn't want to confuse anyone from 1926 or 3026 who might look at it.
-
-
Recent Achievements
-
abortretryfail earned a badge
Week One Done
-
Mr bot earned a badge
First Post
-
Bkl211 earned a badge
First Post
-
Mido gaber earned a badge
One Year In
-
Vladimir Migunov earned a badge
One Year In
-
-
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