What will happen if we declare data type integer of variable and user enters the value out of range of intger? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What will happen if we declare data type integer of variable and user enters the value out of range of intger?

I mean how compiler will react to this problem and with 4 bytes how larger value can we enter?

19th Dec 2016, 12:35 PM
Haseeb Mustafa
2 Answers
+ 3
Sometimes the compiler will crash the system, sometimes it will use the max/min value the variable can hold, that is why we commonly use try-catch statements, try statement for the input, catch statement will occur when user enters the value that is out of the integer range or when the user inputs a value that the variable can't hold.
19th Dec 2016, 12:49 PM
Wen Qin
Wen Qin - avatar
+ 1
it wiol take only integer portion
19th Dec 2016, 12:49 PM
manish rawat
manish rawat - avatar