Advertisement
yoyo106

Read number and calculate sum,product,avg

Apr 23rd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6.     int N,a,x,sum=0,product=1;
  7.     float avg;
  8.     printf("Enter number of integers: ");
  9.     scanf("%d",&N);
  10.     for (a=1;a<=N;a++)
  11.     {
  12.         scanf("%d",&x);
  13.         sum+=x;
  14.         product*=x;
  15.  
  16.     }
  17.         avg=1.0*sum/N;
  18.     printf("Sum = %d\nProduct = %d\nAverage= %.2f",sum,product,avg);
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement