Skip to content

Instantly share code, notes, and snippets.

@kdmkdmkdm
Created April 22, 2012 07:09
Show Gist options
  • Save kdmkdmkdm/2462487 to your computer and use it in GitHub Desktop.
Save kdmkdmkdm/2462487 to your computer and use it in GitHub Desktop.
sumRedditCPlusPlus
// 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