February 4, 2011

C Program for Enter values to continuous loop. If value =0 then break & print sum & average

/*Enter values to continuous loop. If value =0 then break & print sum & average*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,n;
float a,s=0;
clrscr();
while(1)
{
printf("enter the value");
scanf("%d",&n);
i++;
if(n==0)
break;
else
s=s+n;
a=s/i;
}
printf("\nsum=%f",s);
printf("\navg=%f",a);
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories:

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails