1.

Name: Jose Roll no: 20 Age: 17 Weight: 45.650 Consider the above data, we know that there are different types of data are used in the computer. Explain different data types used in C++.

Answer»

1. int data type: 

It is used to store whole numbers without fractional (decimal point) part. It can be either negative or positive. It consumes 4 bytes (32 bits) of memory, i.e. 232 numbers. That is 231 negative numbers and 231 positive numbers (0 is considered as +ve) So a total of 232 numbers. We can store a number in between -231 to + 2311.

2. char data type: 

Any symbol from the keyboard, eg. A’,’9′,…. It consumes one byte( 8 bits) of memory. It is internally treated as integers, i.e. 28 = 256 characters. Each character is having a ASCII code, ‘a’ is having ASCII code 97 and zero is having ASCII code 48.

3. float data type: 

It is used to store real numbers i.e, the numbers with decimal point. It uses 4 bytes(32 bits) of memory. 

eg: 67.89, 89.9 E-15.

4. double data type: 

It is used to store very large real numbers. It uses 8 bytes(64 bits) of memory.

5. void data type: 

void means nothing. It is used to represent a function returns nothing.



Discussion

No Comment Found

Related InterviewSolutions