Sum and average of set of given numbers using while loop #c

//The Program By Tittu Varghese


// To display the sum and average of set of given numbers.

#include<stdio.h>

#include<math.h>

#include<conio.h>

void main()

{

int x,i=1,s=0,n;

float a;

clrscr();

printf("Enter the limit\n");

scanf("%d",&n);

printf("Enter %d numbers\n",n);

while(i<=n)

 {

  scanf("%d",&x);

  s = s+x;

  i=i++;

 }

printf("sum of given %d given number is %d and\n",n,s);

a =s/n;

printf("The average is %f\n",a);

getch();

}

//getch(); is used for hold the out put screen.

//clrscr(); is used for clear the screen. 
//***it must use after variable declaration.

Comments

Popular posts from this blog

Algorithm to display "n" natural numbers #c

Algorithm to display the sum of n natural numbers #c

Algorithm for Sum of two numbers