Examveda

What will be the output of the following C code considering user typed jkl?
#include <stdio.h>
int main()
{
    char n[20];
    fgets(n, 19, stdin);
    ungetc(n[0], stdin);
    printf("%s\n", n);
    return 0;
}

A. jkl

B. kl

C. Undefined behaviour

D. jk

Answer: Option A


This Question Belongs to C Program >> File Input Output

Join The Discussion

Related Questions on File Input Output