"
#include<stdio.h>
#include<conio.h>
void main()
{
int *i,count=1,x=1,sum=0;
//Enter 0 to terminate input
i=(int *)malloc(sizeof(int));
scanf("%d",i);
sum+=*i;
while(i[count-1]!=0)
{
i=(int *)realloc(i,sizeof(int));
scanf("%d",&i[count]);
sum+=i[count];
count++;
}
count--;
printf("\nAverage is: %d",sum/count);
getch();
}
"
#include<stdio.h>
#include<conio.h>
void main()
{
int *i,count=1,x=1,sum=0;
//Enter 0 to terminate input
i=(int *)malloc(sizeof(int));
scanf("%d",i);
sum+=*i;
while(i[count-1]!=0)
{
i=(int *)realloc(i,sizeof(int));
scanf("%d",&i[count]);
sum+=i[count];
count++;
}
count--;
printf("\nAverage is: %d",sum/count);
getch();
}
"
No comments:
Post a Comment