0% found this document useful (0 votes)
13 views

Q1:Write The Name of All Data Type and Their Size Which C++ Allows - Write The Syntax of Each Data Type

The document summarizes the different data types in C++, their sizes, and syntax. It discusses integer (4 bytes), float and double (4 and 8 bytes respectively), character (1 byte), wide character (2 bytes), boolean (true or false), void (no value), long (4 bytes for long integers), short (2 bytes for short integers), and string (text). For each data type it provides the keyword, size, brief description and syntax example to declare a variable of that type.

Uploaded by

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

Q1:Write The Name of All Data Type and Their Size Which C++ Allows - Write The Syntax of Each Data Type

The document summarizes the different data types in C++, their sizes, and syntax. It discusses integer (4 bytes), float and double (4 and 8 bytes respectively), character (1 byte), wide character (2 bytes), boolean (true or false), void (no value), long (4 bytes for long integers), short (2 bytes for short integers), and string (text). For each data type it provides the keyword, size, brief description and syntax example to declare a variable of that type.

Uploaded by

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

Q1:Write the name of all data type and their size which c++ allows.

Write the
syntax of each data type.

INTEGER:
The int keyword is used to indicate integers(digits).
Its size is usually 4 bytes.
Syntax:
int x=56;
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.
Syntax:
Float num=5.88;
Double num=1234.87654;
Character:
Keyword char is used for characters.
Its size is 1 byte.
Syntax:
Char a= ‘A’;
Wchar:
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.
Syntax:
Wchar=’a’
Boolean:
he bool data type has one of two possible values: true or false.
Booleans are used in conditional statements and loops .
Syntax:
bool a=true
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.
We cannot declare variables of the void type.
Syntax:
Long:
It use to store long integer.
Its size is 4 bytes.
Syntax:
long int =54647858097;
Short:
It use to store short integer.
Its size is 2 bytes.
Syntax:
Short int= 5;
String:
It use to print text.
Syntax:
String mytext= “hi”

You might also like