Write a c program that will accept n numbers from user and find their sum and average

#include<stdio.h>
int main()
  {
    int   n, i, sum=0, ava=0;
    printf( "Enter a positive integer number: " );
    scanf( "%d" , &n);
    for(i=1;i<=n;i++)
   sum= sum+i;
    ava=sum/(i-1);
    printf( "\nSum is: %d\nAverage is: %d" , sum, ava);
    return 0;
    }

No comments:

Post a Comment