Question

Which statement best describes what will occur if we execute the following code? int x; x...

Which statement best describes what will occur if we execute the following code?

int x;

x = 11.6;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

When the integer variable is assigned by a float value as given below ,

int x;

x=11.6;

On executionof the code the Compiler performs the implicit conversion which truncates the value and the fractional part is removed . The numbers  after the decimal notation in the float value are lost after the float value is assigned to the integer x . And the value of x will be 11.

Example:

#include <stdio.h>

int main()
{
int x;

x = 11.6;
printf(" value of x is %d ",x);

return 0;
}

Output:

I.lı Result $gcc -o main *.c Smain value of x is 11

Add a comment
Know the answer?
Add Answer to:
Which statement best describes what will occur if we execute the following code? int x; x...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT