A

Admin • 833K Points
Coach

Q. What will be the output of the following C code?

Code:
#include <stdio.h>

int main()
{
float x = 23.456;
printf("%.2f",x);
return 0;
}
  • (A) 23.45600
  • (B) 23.456
  • (C) 23.45
  • (D) 23.46
  • Correct Answer - Option(D)
  • Views: 22
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

In the above code, the value of x is 23.456 and we are printing the value of x using the %.2f format specifier. %.2f rounds the value and prints the 2 digits after the decimal point.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.