Question #243444

Given three numbers A, B, and C. Construct an algorithm to compute and print out the sum, the average, and the product of these values.

Expert's answer

Let A, B, C

Let Sum = A + B + C

Let Avg = (A + B + C) / 3

Let Prod = A * B * C

Print(Sum, Avg, Prod)


Implementation using C++:

#include <iostream>
using namespace std;

int main() {
	int a, b, c;
	cout << "A = ";
	cin >> a;
	cout << "B = ";
	cin >> b;
	cout << "C = ";
	cin >> c;
	int sum = a + b + c;
	float avg = (a + b + c) / 3.0;
	int prod = a * b * c;
	cout << endl;
	cout << "Sum   = " << sum << endl;
	cout << "Average = " << avg << endl;
	cout << "Product = " << prod << endl;
}

Link for testing: https://ideone.com/V3RzaC


LATEST TUTORIALS
APPROVED BY CLIENTS