C Language program to print average of given 3 numbers

Views: 166   

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 <stdio.h>
int main() {
    int input1;
    int input2;
    int input3;

    printf("Enter first number:");
    scanf("%d", &input1);

    printf("Enter second number:");
    scanf("%d", &input2);

    printf("Enter third number:");
    scanf("%d", &input3);

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

    printf("The average of three numbers: %d ", result);


Enter first number: 3
Enter second number: 4
Enter third number: 2
The average of three numbers: 3
On By