what is the size of int? 2 or 4?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the size of int? 2 or 4??

20th Jun 2016, 8:28 PM
Monic@
Monic@ - avatar
10 Answers
+ 5
The C++ standard leaves the size of an int open... On 32bit systems it's 32bits = 4 bytes and on a 64bit system it's 64 bits = 8 bytes. Earlier, on 16 bit systems it was 16bit = 2 bytes. For practical purposes an int can be assumed to be at least 4 bytes on moderately modern PC systems. Also, this depends on the compiler you run, as compilers running on a 32bit system might support creating 64bit code and vice versa.
20th Jun 2016, 8:55 PM
Stefan
Stefan - avatar
+ 1
Hi Humphrey, do you mean if there is a way to determine the actual size of an int on the program you are running? Yes, there is! You can use the *sizeof* operator. It returns the number of bytes a type or variable has. Example: sizeof(int)
20th Jun 2016, 10:40 PM
Stefan
Stefan - avatar
+ 1
it is depends on which compiler you use
22nd Jun 2016, 3:11 PM
gandhiyash
+ 1
size of int depends on compiler.
13th Jul 2016, 7:59 AM
B. K.
0
4
20th Jun 2016, 8:39 PM
Sardor
Sardor - avatar
0
4 bytes
20th Jun 2016, 8:41 PM
destro
0
4
20th Jun 2016, 10:10 PM
Barış Yağız
Barış Yağız - avatar
0
please I have no... idea whatsoever of C++. need small tutorials
21st Jun 2016, 9:25 AM
Aboagye Joseph
Aboagye Joseph - avatar
0
yahoooo!!!!!!!!
15th Jul 2016, 7:09 PM
Varun Bc
Varun Bc - avatar
- 1
Can a value also determine how big or small between 2 to 4 bytes they are?
20th Jun 2016, 10:15 PM
Humphrey J. Pachecker
Humphrey J. Pachecker - avatar