Tech Blog » Home » Coders Forum » Computer Directory » Math Calculators » RSS:Directory|Forum
C++ Source Code: Implementations, Beginners
C++ Adding » Visual Studio: Compiler » C++ vs JAVA » C++ Source Code Coders Community: Forum
// =======================================================
// This program adds two numbers and then averages them.
// =======================================================
#include <iostream>
using namespace std;
int main ()
{
double num1 = 0;
double num2 = 0;
double total = 0;
double avg = 0;
cout << "Please enter a number: ";
cin >> num1;
cout << "Please enter a second number: ";
cin >> num2;
total = num1 + num2;
cout << "\nThe total of the two numbers is: " << total << "\n";
avg = (total / 2);
cout << "The average of the two numbers is: " << avg << "\n\n";
return 0;
}
/* ===================== output ==================================
Please enter a number: 88.6
Please enter a second number: 75.3
The total of the two numbers is: 163.9
The average of the two numbers is: 81.95
Press any key to continue . . .
*/// =============================================================