Dremendo Tag Line

Print sum and average of 5 numbers in C

printf() - Question 10

In this question, we will see how to print the sum and average of 5 numbers in C programming using the printf() function. To know more about printf() function click on the printf() function lesson.

Q10) Write a program in C to print the sum and average of 5 number like 9, 5, 8, 34, and 15.

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    printf("Sum of of 9, 5, 8, 34, and 15 = %d\n",9+5+8+34+15);
    printf("Average of 9, 5, 8, 34, and 15 = %f",(9+5+8+34+15)/5.0);
    return 0;
}

Output

Sum of of 9, 5, 8, 34, and 15 = 71
Average of 9, 5, 8, 34, and 15 = 14.200000
video-poster