C program to Find the Sum and Average of Three Numbers

Write a C program to find the sum and average of three numbers. This C example accepts three integer values and calculates the sum and average of those three numbers.

#include <stdio.h>

int main()
{   
    int num1, num2, num3, sum;
    float avg;
    
    printf("Enter the First Number  = ");
    scanf("%d",&num1);

    printf("Enter the Second Number = ");
    scanf("%d",&num2);

    printf("Enter the Third Number  = ");
    scanf("%d",&num3);
    
    sum  = num1 + num2 + num3;

    avg = sum / 3;

    printf("\nThe Sum of Three Numbers     = %d", sum); 
    printf("\nThe Average of Three Numbers = %.2f\n", avg);
}
C program to Find the Sum and Average of Three Numbers

This c program finds the sum and average of three floating point numbers.

#include <stdio.h>

int main()
{   
    float num1, num2, num3, sum, avg;
    
    printf("Enter the First Float Number  = ");
    scanf("%f",&num1);

    printf("Enter the Second Float Number = ");
    scanf("%f",&num2);

    printf("Enter the Third Float Number  = ");
    scanf("%f",&num3);
    
    sum  = num1 + num2 + num3;

    avg = sum / 3;

    printf("\nThe Sum of Three Numbers      = %.2f", sum); 
    printf("\nThe Average of Three Numbers  = %.2f\n", avg);
}
Enter the First Float Number  = 22.5
Enter the Second Float Number = 55.9
Enter the Third Float Number  = 128.7

The Sum of Three Numbers      = 207.10
The Average of Three Numbers  = 69.03