Home / C Programming / Library Functions :: Discussion

Discussion :: Library Functions

  1. What will be the output of the program?

     #include 
      int main()
      {    
          int i;    
          i = scanf("%d %d", &i, &i);       
          printf("%d\n", i); 
          return 0; 
      }
    

  2. A.

    1

    B.

    2

    C.

    Garbage value

    D.

    Error: cannot assign scanf to variable

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    scanf() returns the number of variables to which you are provding the input.

    i = scanf("%d %d", &i, &i); Here Scanf() returns 2. So i = 2.

    printf("%d\n", i); Here it prints 2.


Be The First To Comment