# Plus One Computer Application Notes Chapter 5 Data Types and Operators

Students can Download Chapter 5 Data Types and Operators Notes, Plus One Computer Application Notes helps you to revise the complete Kerala State Syllabus and score more marks in your examinations.

## Kerala Plus One Computer Application Notes Chapter 5 Data Types and Operators

Concepts of data types: The nature of data is different, data type specifies the nature of data we have to store.

C++ data types Fundamental data types: It is also called built in data type. They are int, char, float, double and void
i) 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 + 231 – 1.

ii) 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.

iii) float data type: It is used to store real numbers he. the numbers with decimal point. It uses 4 bytes(32 bits) of memory.
Eg. 67.89, 89.9 E-15.

iv) double data type: It is used to store very large real numbers. It uses 8 bytes(64 bits) of memory.

v) void data type: void means nothing. It is used to represent a function returns nothing.
User defined Data types: C++ allows programmers to define their own data type. They are Structure(struct), enumeration (enum), union, class, etc.
Derived data types: The data types derived from fundamental data types are called Derived data types. They are Arrays, pointers, functions, etc

Variables:
The named*memory locations are called variable. A variable has three important things

1. variable name: A variable should have a name
2. Memory address: Each and every byte of memory has an address. It is also called location (L) value
3. Content: The value stored in a variable is called content.lt is also called Read(R) value.

Operators: An operator is a symbol that performs an operation. The data on which operations are carried out are called operands. Following are the operators
1) Input(>>) and output(<<) operators are used to perform input and output operation. Eg. cin>>n;
cout<<n;

2) Arithmetic operators: It is a binary operator. It is used to perform addition(+), subtraction(-), division (/), multiplication(*) and modulus(%-gives the remainder) operations.
Eg. If x = 10 and y = 3 then x/y = 3, because both operands are integer. To get the floating point result one of the operand must be float.

3) Relational operator: It is also a binary operator. It is used to perform comparison or relational operation between two values and it gives either true(1) or false(0). The operators are <, <=, >, >=, == (equality)and !=(not equal to)
Eg. If x = 10 and y = 3 then 4) Logical operators: Here AND(&&), OR(||) are binary operators and NOT (!) is a unary operator. It is used to combine relational operations and it gives either true(1) or false(0).
If x = 1 and y = 0 then Both operands must be true to get a true value in the case of AND (&&) operation.
If x = 1 and y = 0 then Either one of the operands must be true to get a true value in the case of OR(||) operation
If x = 1 and y = 0 then 5) Conditional operator: It is a ternary operator hence it needs three operands. The operator is?:. Syntax: expression ? value if true: value if false. First evaluates the expression if it is true the second part will be executed otherwise the third part will be executed.
Eg. If x = 10 and y = 3 then
x>y ? cout<>) operator is used to perform input operation.
Eg. cin>>n;

Output statements
output(<<) operator is used to perform output operation.
Eg. cout<<n; Cascading of I/O operations The multiple use of input or output operators in a single statement is called cascading of i/o operators. Eg: To take three numbers by using one statement is as follows cin>>x>>y>>z;
To print three numbers by using one statement is as follows
cout<<x<<y<<z;