Write a program to calculate the average of three real numbers.

#include<stdio.h>

int main()

  int a,b,c, sum; 

  float d; 

  printf(“Please enter 3 numbers”); 

  scanf(“%d%d%d”,&a,&b,&c); 

  sum=a+b+c;

  d=(a+b+c)/3; 

  printf(“\nSum is %d”, sum); 

  printf(“\nAverage is  %f”,d);

  return 0;

}

Output

Please enter 3 numbers: 4 6 2

Sum is 12

Average is  4.000000

Leave a Reply

Your email address will not be published. Required fields are marked *