Answer to Question #243444 in Algorithms for Bjoy

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.
1
Expert's answer
2021-09-29T03:16:54-0400

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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS