0% found this document useful (0 votes)
31 views9 pages

Fundamentals of Computer Programming

C++ has several fundamental data types including int, float, double, char, wchar_t, bool, and void. The document describes the size and usage of each data type. Integers are usually 4 bytes and store whole numbers. Float and double store decimals and exponentials at 4 and 8 bytes respectively. Char stores single characters at 1 byte while wchar_t stores wider characters at 2 bytes. Bool stores true or false values. Void indicates no data type.

Uploaded by

Isuru Madushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

Fundamentals of Computer Programming

C++ has several fundamental data types including int, float, double, char, wchar_t, bool, and void. The document describes the size and usage of each data type. Integers are usually 4 bytes and store whole numbers. Float and double store decimals and exponentials at 4 and 8 bytes respectively. Char stores single characters at 1 byte while wchar_t stores wider characters at 2 bytes. Bool stores true or false values. Void indicates no data type.

Uploaded by

Isuru Madushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Fundamentals

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

• Data types are very useful in declaring variables in programming.


C++ Fundamental Data Types
Data Type Meaning Size (in Bytes)

int Integer 2 or 4

float Floating-point 4

double Double Floating-point 8

char Character 1

wchar_t Wide Character 2

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';

• Strings : Bunch of characters

String sName = "Amal";


4. C++ wchar_t
• Wide character wchar_t is similar to the char data type, except its
size is 2 bytes instead of 1.
• It is used to represent characters that require more memory to
represent them than a single char.
For example,
• wchar_t test = L'‫ 'ם‬// storing Hebrew character;

5. C++ bool
• The bool data type has one of two possible values: true or false.
• Booleans are used in conditional statements and loops (which we will
learn in later chapters).
For example,
• bool cond = false;
6. C++ void
• The void keyword indicates an absence of data. It means "nothing"
or "no value".
• We will use void when we learn about functions and pointers.
• Note: We cannot declare variables of the void type.

• Void marks = 75; wrong

You might also like