...

/

Primitive or Fundamental Data Types

Primitive or Fundamental Data Types

Learn about fundamental data types.

Integer data type

The integer data type comprises all positive and negative whole numbers. We use the int keyword to define the integer data type. A variable of int type is allocated 4 bytes of memory. It can store any value from -231 to 231-1.

int integer_number = 100;

💡Do you know? If you store 100.5 in a variable of integer type, it would be truncated to 100.

Floating-point data type

The floating-point data type contains a number with a fractional part. We use the float keyword to define the floating-point data type. A variable of a float type is allocated 4 bytes of memory. It can store any value in the range of ±3.40±3.40 ...