Q1: What are different types of variable?
Answer:
A predefined word which have a specific meaning in compiler. These are types of variable.
1. Integer:
It used to store integer value. Keyword use for integer is 'int'. It requires 4 bytes of memory.
2. Character:
It used to storing characters. Keyword use for character is 'char'. It requires 1 byte of memory space.
3. Boolean:
It used for storing logical values. It stores either true or false. Keyword use for Boolean is 'bool'.
4. Floating:
It used for storing decimal value. Keyword used for floating point is 'float'. It requires 4 byte of memory space.
5. Double:
It used for storing double precision floating point values. Keyword used for double floating point is 'double'. It requires 8 byte of memory space.
Q2: What are relation, arithmetic, & logical operators?
Answer:
Relational operators:
The relational operators are used to test a relation between two expressions.
1. Greater then >
2. Greater than or equal to >=
3. Less then <
4. Less then or equal <=
5. Equal to ==
6. Not equal to !
Arithmetic Operators:
1. Addition +
2. Subtracts -
3. Multiplies *
4. Divide \
5. Modulus %
Logical operators:
1. AND (&&):
When "And" is used it give answer is true only when both conditions is true. If one is false then it gives answer false.
2. OR (| |):
When "Or" is used it give answer is false only when both conditions is false. If anyone is true it give answer is true.
3. NOT (!):
When "Not" is used it reverse its answer. If answer is false it changes in true. If answer is true it changes in false.
Q3: What is precedence of arithmetic operations?
Answer:
Precedence:
Precedence of arithmetic operations in c++ is same as in mathematics.
Bracket ( )
Division /
Modulus %
Multiply *
Addition +
Subtract -
No comments:
Post a Comment