Count the Digits

Test your C programming skills by solving the given puzzle about the format specifier.

Puzzle code

Read carefully the code given below:

Press + to interact
#include <stdio.h>
#include <math.h>
int main()
{
printf("%2.4f\n", M_PI); /* M_PI = 3.14159265358979323846 */
return(0);
}

Your task: Guess the output

Attempt the following test to assess your understanding.

Q

What is the expected output of the above code?

A)

3.14159265358979323846

B)

3.1416

C)

3.15

D)

3.2

Let's discuss the code and output together in the next lesson.