Home » C Programming » C-Library-Functions » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int num;
    scanf("%d", &num);
    ungetc(num, stdin);
    scanf("%d", &num);
    printf("%d\n", num);
    return 0;
    }
    1. Whatever is typed by the user first time
    2. Undefined behaviour
    3. Compilation Error
    4. Whatever is typed by the user second time
    5. None of these
Correct Option: B

Undefined behaviour



Your comments will be displayed only after manual approval.