Definition of Int in C, C++ and C#

An int variable contains only whole numbers

Illuminated numbers on a digital display
​Thomas M. Scheer/EyeEm/Getty Images

Int, short for "integer," is a fundamental variable type built into the compiler and used to define numeric variables holding whole numbers. Other data types include float and double.

C, C++, C# and many other programming languages recognize int as a data type. 

In C++, the following is how you declare an integer variable:

int a = 7; 

Int Limitations

Only whole numbers can be stored in int variables, but because they can store both positive and negative numbers, they're also considered signed.

For example, 27, 4908 and -6575 are valid int entries, but 5.6 and b are not. Numbers with fractional parts require a float or double type variable, both of which can contain decimal points.

The size of number that can be stored in int usually is not defined in the language, but instead depends on the computer running the program. In C#, int is 32 bits, so the range of values is from -2,147,483,648 to 2,147,483,647. If larger values are required, the double type can be used.

What Is Nullable Int?

Nullable int has the same range of values as int, but it can store null in addition to whole numbers. You can assign a value to nullable int just as you would for int, and you can also assign a null value. 

Nullable int can be useful when you want to add another state (invalid or uninitialized) to a value type. Nullable int cannot be used in loops since loop variables must always be declared as int.

Int vs. Float and Double

Int is similar to the float and double types, but they serve different purposes.


  • Takes up less space than other types 
  • Has faster arithmetic
  • Uses only whole numbers
  • Uses caches and data transfer bandwidth more efficiently

Float and double types:

  • Uses twice as much memory
  • Can contain a decimal point
  • Can contain more characters

The difference between float and double types lies in the range of values. The range of double is twice that of float, and it accommodates more digits.

Note: INT is also used as a formula in Microsoft Excel to round numbers down, but it has nothing to do with int as described on this page.

mla apa chicago
Your Citation
Bolton, David. "Definition of Int in C, C++ and C#." ThoughtCo, Aug. 28, 2020, Bolton, David. (2020, August 28). Definition of Int in C, C++ and C#. Retrieved from Bolton, David. "Definition of Int in C, C++ and C#." ThoughtCo. (accessed March 30, 2023).