/*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.. :)#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();
}
Categories:
c program
0 comments:
Post a Comment