In C++, if a floating-point number is assigned to an integer type, the value will be ______.

  • Rounded Up
  • Truncated
  • Type Error
  • Undefined
When a floating-point number is assigned to an integer type in C++, the value will be truncated. This means that the fractional part of the floating-point number is discarded, and only the whole number part is stored in the integer variable. It's essential to be aware of this behavior to prevent unexpected results in your code.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *