LiveExample: ComputeAverage.cpp
Source Code Editor:
#include <iostream> using namespace std; int main() { // Prompt the user to enter three numbers double number1, number2, number3; cout << "Enter three numbers: "; FILL_CODE_OR_CLICK_ANSWER // Compute average double average = FILL_CODE_OR_CLICK_ANSWER; // Display result cout << "The average of " << number1 << " " << number2 << " " << number3 << " is " << average << endl; return 0; }
Enter input data for the program (Sample data provided below. You may modify it.)
1.5 2.3 7.1
Choose a Compiler:
VC++
GCC
Execution Result:
command>cl ComputeAverage.cpp Microsoft C++ Compiler 2019 Compiled successful (cl is the VC++ compile/link command) command>ComputeAverage Enter three numbers: 1.5 2.3 7.1 The average of 1.5 2.3 7.1 is 3.63333 command>
#include <iostream> using namespace std; int main() { // Prompt the user to enter three numbers double number1, number2, number3; cout << "Enter three numbers: "; FILL_CODE_OR_CLICK_ANSWER // Compute average double average = FILL_CODE_OR_CLICK_ANSWER; // Display result cout << "The average of " << number1 << " " << number2 << " " << number3 << " is " << average << endl; return 0; }