C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - Find Output of Program (Q.No. 13)
13.
What will be the output of the program if value 25 given to scanf()?
#include<stdio.h>
int main()
{
int i;
printf("%d\n", scanf("%d", &i));
return 0;
}
Answer: Option
Explanation:
The scanf function returns the number of input is given.
printf("%d\n", scanf("%d", &i)); The scanf function returns the value 1(one).
Therefore, the output of the program is '1'.
Discussion:
23 comments Page 3 of 3.
Vjagtap said:
6 years ago
Then what is 25 ?
Shaikh Sahil said:
3 years ago
If scanf is given 25 then why it is returning 1?
Can anyone please explain me?
Can anyone please explain me?
CHALLA SANTHOSH said:
11 months ago
The scanf keyword is used inside the printf.
So the scanf will do that it will take inputs but it will return how many inputs are taken.
So if there is only one integer it will return one if there is two inputs for the scanf it will return two.
So the scanf will do that it will take inputs but it will return how many inputs are taken.
So if there is only one integer it will return one if there is two inputs for the scanf it will return two.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers