What will be the output of the following C code?
#include <stdio.h>
int main()
{
char n[20];
fgets(n, 19, stdin);
ungetc(n[0], stdin);
scanf("%s", n);
printf("%s\n", n);
return 0;
}
#include <stdio.h>
int main()
{
char n[20];
fgets(n, 19, stdin);
ungetc(n[0], stdin);
scanf("%s", n);
printf("%s\n", n);
return 0;
}A. Compile time error
B. Whatever string user types second time
C. Whatever string user types first time
D. First character of whatever user types first time and whatever user types second time
Answer: Option D

Join The Discussion