94.2k views
5 votes
Assume the following variable declaration exists in a program:

double number = 1234567.456;
What format specifier should be inserted in the statement below to display the value of the number variable formatted as '1,234,567.46'?

printf("_______", number);
A) %d
B) %lf
C) %.2lf
D) %,.2lf

Please select the correct option.

User Mustafa
by
7.3k points

1 Answer

3 votes

Final answer:

The correct format specifier to display the value of the number variable formatted as '1,234,567.46' is %.2lf.

Step-by-step explanation:

The correct format specifier to display the value of the number variable formatted as '1,234,567.46' is %.2lf. This format specifier is used to display a double value with two decimal places.

Using this format specifier, the correct printf statement would be:

printf("%.2lf", number);

User Abhishek Jangid
by
8.1k points