+ 3

Please tell me friends the output of this code? Print("% d ",scanf("%d",&i))

I'm rate submissions

9th Feb 2017, 8:27 AM
Shravan K Malviya
Shravan K Malviya - avatar
3 Respostas
+ 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.
9th Feb 2017, 9:01 AM
ChaoticDawg
ChaoticDawg - avatar
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);
9th Feb 2017, 9:14 AM
Ehsan Bojnordi
Ehsan Bojnordi - avatar
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.
9th Feb 2017, 9:26 AM
ChaoticDawg
ChaoticDawg - avatar