0
I haven't found the option for enter multiple value with the scanf function, plzz help me out
#include <stdio.h> int main() { int a[3],i,sum; float avg; for(i=0;i<=2;i++) { scanf("%d",&a[i]); } for(i=0;i<=2;i++) { sum=sum+a[i]; avg=sum/3.0; printf ("%f",avg); } }
1 Respuesta
+ 1
If u claculating average of 3 number
then change some line see this code where i change some lines in 2nd loop
#include<stdio.h>
int main()
{
int a[3],i,sum;
float avg;
for(i=0;i<=2;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=2;i++)
{
sum=sum+a[i];
}
avg=sum/3.0;
printf ("%f",avg);
}
Give i/p like this
2
4
6
then u get 4.00
hope you understand.