- 0
[C++] Tutorial #1 Simple Sum/Average
Asked by
coolbunny1234,
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Copernic · Posted
dBpoweramp Music Converter 2025-06-05 by Razvan Serea Audio conversion perfected, effortlessly convert between formats. dBpoweramp contains a multitude of audio tools in one: CD Ripper, Music Converter, Batch Converter, ID Tag Editor and Windows audio shell enhancements. Preloaded with essential codecs (mp3, wave, FLAC, m4a, Apple Lossless, AIFF), additional codecs can be installed from [Codec Central], as well as Utility Codecs which perform actions on audio files. After 21 days the trial will end, reverting to dBpoweramp Free edition (learn the difference between Reference and dBpoweramp Free, here). dBpoweramp is compatible with Windows 10, 8, 7, Vista, both 32 and 64 bit. dBpoweramp Music Converter features: Convert audio files with elegant simplicity. mp3, mp4, m4a (iTunes / iPod), Windows Media Audio (WMA), Ogg Vorbis, AAC, Monkeys Audio, FLAC, Apple Lossless (ALAC) to name a few! Multi CPU Encoding Support Rip digitally record audio CDs (with CD Ripper) Batch Convert large numbers of files with 1 click Windows Integration popup info tips, audio properties, columns, edit ID-Tags DSP Effects such as Volume Normalize, or Graphic EQ [Power Pack Option] Command Line Encoding: invoke the encoder from the command line DSP Effects - process the audio with Volume Normalize, or Sample / Bit Rate Conversion, with over 30 effects dBpoweramp is a fully featured mp3 Converter dBpoweramp integrates into Windows Explorer, an mp3 converter that is as simple as right clicking on the source file >> Convert To. Popup info tips, Edit ID-Tags are all provided. dBpoweramp Music Converter 2025.06.05 changelog: Darkmode added Core Converter Debug log dumps ID Tags written VST Effect Folders dialog fixed missing InitCommonControls would not show correctly FLAC/Ogg/Opus/etc - allows editing of CDTOC ID Tag CD Ripper secure ripping log where shows TOC was not showing CD Extra correctly CD Ripper was incorrectly setting data track length on main display (for certain drives) CD Ripper internally better handling of corrupt TOCs CD TOC to Tag was incorrectly adding 150 to CD Extra disc CD Ripper shows "AccurateRip Unconfigured" in rip status rather than "not in accuraterip" if unconfigured CD Ripper art paste accepts https CueSheet added as standard - log file written to same folder as cue and folder.jpg AIFF internal code merge (macos >> windows) Download: dBpoweramp Music Converter R2025.06.05 | 82.2 MB (Shareware) View: dBpowerAMP Music Converter Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware -
-
By Slugsie · Posted
Staged. It's a requirement that vehicles are strapped down to the bed. Usually wheel and/or chassis tie downs are used. That appears to just be on the winch. -
By stevember · Posted
I feel Apple's big problem is the lack of big data to train any AI LLM model. They have statistics on usage, but they don't have the written social media, messaging (they were early adopters of end-to-end encryption), they didn't scrape the Internet before the book companies and new sources were wise. So they have no choice but to use a third party LLM provider. Which ties them in knots with their own stance on security and privacy. In short, they are royally stuffed when it comes to developing an in-house AI. -
By samw61 · Posted
Nothing is black and white. Democracy can suck, just as communism can. The risk is people who blindly think one is vastly superior over the other. Democracy needs a lot to make it work well, and there are many examples around the world of it. Good education, mandatory voting, accessible voting, and removing money from politics are just a few elements that need to be sorted for a functional democracy. The USA is the playbook on what not to do with democracy.
-
-
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