Multiple choice

Find the output of the following code in C language assuming other parameters are correct. void main( ) { int a; int b; scanf ("%2d %5d", &a, &b); printf ("a = %d and b=%d.",a,b); }
/* input by the user is a=12345 and b = 67 during program execution*/

  1. a=12345 and b=67

  2. a=67 and b=12345

  3. a=12 and b=345

  4. a=12 and b=34567

  5. a=12 and b=67

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

%2d will restrict scanf function to assign only 2 digits in the variable a and rest of the digits will be assigned to the next scanf variable i.e. b.