Examveda

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    ungetc(n, stdin);
    scanf("%d", &n);
    printf("%d\n", n);
    return 0;
}

A. Compile time error

B. Whatever is typed by the user first time

C. Whatever is typed by the user second time

D. Undefined behaviour

Answer: Option B


This Question Belongs to C Program >> File Input Output

Join The Discussion

Related Questions on File Input Output