In case of the following type conversions, what is the output of the program?
#include <iostream>

int main() {
    float a = 256.5;
    unsigned char b = static_cast<unsigned char>(a);
    a += b + 1.f;
    std::cout << static_cast<int>(a);
Floating-integral conversions
An rvalue of a floating-point type can be converted to an rvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Зареєструйся Зараз
або Підпишись на майбутні тести