0
Int vs Var?
I just looked at a test on Solo Learn. it asked me to finish the code by filling in the blanks, so I did. it said I was wrong by typing "var" instead of "int" for a code with math? technically, I should be able to declare the whole number a variable.. right?
3 Answers
+ 4
@kinshuk i think in use we can only store -(2^31) to ((2^31)-1)as one bit will be used as most significant bit for determining wether the number is positive or not.
+ 3
var isn't available in c++. Try using auto.
You see, all things you declare like this:
int a, b, var;
Are variables. You can store any value that corresponds to the type specified during creation. For eg, a is an int. You may not store 2.2 (Real Number) in this variable. But you may store any integer in the range -(2^32) to 2^32-1 in this variable.
+ 2
@Shobhit
Yes the limits are -2^31 to 2^31-1, but actually integers use two complement form to store negative numbers.