Fundamentals of Computer Programming
Fundamentals of Computer Programming
of Computer Programming
By: Deshan Bulathsinghala (BSc In MIS UCD-Ireland, MSc in IT (Rdg –
UCSC)
Lecturer – Faculty of Information Technology and Sciences
International College of Business and Technology
C++ Data Types
int Integer 2 or 4
float Floating-point 4
char Character 1
bool Boolean 1
void Empty 0
1. C++ int
• The int keyword is used to indicate integers.
• Its size is usually 4 bytes. Meaning, it can store values from -
2147483648 to 214748647.
For example,
• int salary = 85000;
2. C++ float and double
• float and double are used to store floating-point numbers
(decimals and exponentials).
• The size of float is 4 bytes and the size of double is 8 bytes.
Hence, double has two times the precision of float. To learn more,
visit C++ float and double.
For example,
• float area = 64.74;
• double volume = 134.64534;
• As mentioned above, these two data types are also used for
exponentials. For example,
• double distance = 45E12 // 45E12 is equal to
45*10^12
3. C++ char
• Keyword char is used for characters.
• Its size is 1 byte.
• Characters in C++ are enclosed inside single quotes ' '.
For example,
• char test = 'd';