Created
April 22, 2012 07:09
-
-
Save kdmkdmkdm/2462487 to your computer and use it in GitHub Desktop.
sumRedditCPlusPlus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sumReddit.cpp | |
#include "stdafx.h" | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// Declare. | |
float first = 0.0f; | |
float second = 0.0f; | |
float third = 0.0f; | |
float fourth = 0.0f; | |
float fifth = 0.0f; | |
float sum = 0.0f; | |
float average = 0.0f; | |
// first - fifth input. | |
cout << "Enter your first number: "; | |
cin >> first; | |
cout << endl; | |
cout << "Enter your second number: "; | |
cin >> second; | |
cout << endl; | |
cout << "Enter your third number: "; | |
cin >> third; | |
cout << endl; | |
cout << "Enter your fourth number: "; | |
cin >> fourth; | |
cout << endl; | |
cout << "Enter your fifth number: "; | |
cin >> fifth; | |
cout << endl; | |
// Sum equation. | |
sum = first + second + third + fourth + fifth; | |
// Sum output. | |
cout << "The sum of these numbers is: " << sum << endl; | |
// Average equation. | |
average = (first + second + third + fourth + fifth) / 5; | |
// Average output. | |
cout << "The average of these numbers is: " << average << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment