0
Why is this program taking 6 input instead of 5.
#include<stdio.h> int sum (int,int,int,int,int); int average(int); //float deviation(float); int main() { int a,b,c,d,e,p,q; printf("enter the 5 number\n"); scanf("%d%d%d%d%d\n",&a,&b,&c,&d,&e); p=sum(a,b,c,d,e); printf(" sum=%d",p); q=average(p); printf(" avg=%d",q); return 0; } int sum (int x,int y,int z,int m,int n) { int s; s=x+y+z+m+n; return (s); } int average (int r) { int t; t=r/5; return (t); }
7 odpowiedzi
+ 3
Remove \n from scanf format specifier, and also put spaces in between %d ...
scanf("%d %d %d %d %d" ,&a, &b, &c, &d, &e);
Use \n for inserting line breaks when printing outputs (using printf()). Not when reading input (using scanf()).
+ 6
Ravi anshuman Hello,you code working properly,take only 5 numbers as input...
https://code.sololearn.com/cM7r2F3LzR6O/?ref=app
+ 6
Ipang but his code working properly..
Ravi anshuman no errors in your code it works properly, just give 5 number in input
+ 2
This program is only taking 5 inputs..
+ 2
In Code Playground yes,
But not when I test ran it in CDroid
Test it in offline compiler bro ...
+ 1
@ipan thanks.....that was a terrible mistake.
+ 1
No problem Ravi we're all humans bro 👌