Question:

What's the output of the following program and why? ?

by  |  earlier

0 LIKES UnLike

int main()

{

float a = 12.5;

printf("%d\n", a);

printf("%d\n", *(int *)&a);

return 0;

}

 Tags:

   Report

2 ANSWERS


  1. Hi there.

    The output will be zero as you have assigned float value but are using %d at the place of %f .

    output will look like:

    0

    0

    I think I answered it .

    Good Luck.


  2. I think the answer will be like this:

    12

    12

    Because as far as I know, when you use %d for a float or double number, it automatically round it off.

    Good luck

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions