logo image

C++ program to print average of given 3 numbers

63


Following program shows you how to print average of given 3 numbers. In this program we get inputs from user and calculate average of given 3 numbers using following formula Average of given 3 numbers = (input1 + input2 + input3) / 3

#include <iostream>

int main() {
	int input1;
	int input2;
	int input3;

	std::cout << "Enter first number:";
	std::cin >> input1;

	std::cout << "Enter second number:";
	std::cin >> input2;

	std::cout << "Enter thrid number:";
	std::cin >> input3;

	int result = (input1 + input2 + input3) / 3;

	std::cout << "The average of three numbers is: " << result;
}

Output:

Enter first number: 6
Enter second number: 7
Enter thrid number: 3
The average of three numbers is: 5