FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 80   



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



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News