#include <iostream> int main(int argc, char **argv) { std::cout << 25u - 50; return 0; } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

#include <iostream> int main(int argc, char **argv) { std::cout << 25u - 50; return 0; }

Explanation please ..

21st Jul 2020, 1:17 PM
i Ebenezer
2 Answers
+ 3
Hey you can test your code in Code Playground ... Unless you wanted an explanation, for which you'd be asking for explanation rather than "Answer.?" https://www.sololearn.com/Codes/
21st Jul 2020, 1:24 PM
Ipang
0
25U is an unsigned integer literal. Unsigned integer does not support negative values, that's why when you subtract (unsigned int) 25 you got a big number. Unsigned integer unit size is approximately 4 bytes (32bit) and it support a range of value from 0 up to 4294967295 (2 raised to the power of 32, minus 1). The big value you got there was max value for unsigned int subtracted by 25. Why 25? because the first 25 out of the 50 had subtracted 25U down to zero.
22nd Jul 2020, 5:38 AM
Ipang