I haven't found the option for enter multiple value with the scanf function, plzz help me out | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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); } }

19th Apr 2020, 11:28 AM
saurabh singh
1 Answer
+ 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.
20th Apr 2020, 4:08 AM
VIVEK NIRMALKAR
VIVEK NIRMALKAR - avatar