C - What is the output: printf("The total is %d\n",16.0+17)?

Question

What is the output of the following code?

#include <stdio.h>

int main()
{
    printf("The total is %d\n",16.0+17);
    return(0);
}


Click to view the answer

The total is 1606416648

Note

The compiler reads value 16.0 as a float because of the .0 part.

The value 17 is still assumed to be an int.

It's the printf() function trying to interpret what's become a floating point value as an int because of %d.

Related Exercise