cbse class xi :- operators in c++

Post on 22-May-2015

763 Views

Category:

Education

8 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Operators Operators in in

C ++C ++

Made By:- Pranav GhildiyalMade By:- Pranav GhildiyalClass :- ‘XI’ ‘B’Class :- ‘XI’ ‘B’

ARITHEMATIC OPERATORS

PLEASE NOTE :- C++ is case- sensitive a , A both

are different

Unary plus

A= 5A= 5

Unary minus

-A = -5-A = -5

INCREMENT AND DECREMENT OPERATOR INCREMENT AND DECREMENT OPERATOR INCREMENT AND DECREMENT OPERATOR INCREMENT AND DECREMENT OPERATOR

• These operators increase or decrease the value of the operand by 1

• Increment increases by 1 while the decrement decreases by 1

PREFIX VERSION

It follows the change then use rule i.e., it first changes the value of the operand and then use the new value to evaluate the expression

POSTFIX VERSION

It follows the use then change rule i.e., it first uses the new value of the operand in evaluating the expression and then changes the operands value

.Operators that act upon two operands

are known as binary operators

Relational operators refer to the relationship that values can have with one another . Relational operators don’t work with string. We can compare numbers and characters with them. If the comparison results in true , the relational operators results in the value 1 else it results in the value 0 (comparison results in false).

LOGICAL OPERATORS LOGICAL OPERATORS

Logical AND

The resulting expressions gives the value 1 only if both the original operands are true

Logical OR

The resulting expressions gives the value 1 if either of the original operands is true

Logical NOT

It is a unary operator. It reverses the truth value of the expression and gives true if the expression is false

11 Logical OR and Logical AND has lower precedence than relational operatorsLogical OR and Logical AND has lower precedence than relational operators

22 Logical NOT has higher precedence over any relational or arithimatic operator Logical NOT has higher precedence over any relational or arithimatic operator

Facts about operators Facts about operators

CONDITIONAL OPERATOR ( ? : ) OR TERNARY OPERATORCONDITIONAL OPERATOR ( ? : ) OR TERNARY OPERATORCONDITIONAL OPERATOR ( ? : ) OR TERNARY OPERATORCONDITIONAL OPERATOR ( ? : ) OR TERNARY OPERATOR

SOME OTHER OPERATORSSOME OTHER OPERATORS

COMPILE TIME OPERATOR

• It returns the length (in bytes) of the variable / type specified

COMMA OPERATOR

Integer Integer 2 Bytes2 Bytes

CharacterCharacter 1 Bytes1 Bytes

Float Float 4 Bytes4 Bytes

Double Double 8 Bytes8 Bytes

• It is used to string together several group of expressions. The result of the rightmost expression becomes the value of the total comma seprated expression

top related