C - Files - Discussion

You Are Here :: Home > C > Files - Discussion

 



Q.

What is the output of this C code?

#include
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
Explaination:

("%2.1f\n", a); The precision specifier tells .1f tells the printf function to place only one number after the .(dot).Hence the output is 3.2



Discussion

Your Comments Goes here...
NameDiscussion