Multiple choice

What will be the output of the following function?

main() { int i; printf(%d,scanf(%d,&i));
// value 10 is given as input here }

  1. 1

  2. 10

  3. Garbage value

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The scanf function returns the number of items successfully read and assigned. Since one integer is successfully scanned into variable i, scanf returns 1, which is then printed by the outer printf.