+ 3
Please tell me friends the output of this code? Print("% d ",scanf("%d",&i))
I'm rate submissions
3 Antworten
+ 1
int i;
printf("%d", scanf("%d", &i));
%d in both cases refers to a decimal
scanf will get input from the user. In this case of type int %d.
It uses &i to access the memory address of the variable i so that the input value can be put into it.
It then returns the number of item it successfully filled. In this case 1 or 0.
1 is what is output if successful otherwise 0.
0
Briefly, this code gets the integer number as i then it writes value of i in the output.
its equal to this code:
int i;
scanf("%d", &i);
printf(%d",i);
0
@Ehsan Bojnordi
it won't print the value of i. It will print the return value of the scanf method, which will be either 1 if successful or 0.