Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.4k views
in Data Types and Operators by (32.9k points)
closed by

Define an operator and explain operator in detail.

1 Answer

+1 vote
by (30.8k points)
selected by
 
Best answer

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) lnput(>>) 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 x-y x*y x/y x%y
13 7 30 3 1

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 opera- tor. It is used to perform comparison or relational operation between two values and it gives either true(1) px false(O). The operators are ,>=,== (equallty)and != (not equal to) 

Eg. If x-10 and y=3 then

x<y x<=y x>y x>=y x==y x!=y
False False True True False True

4) Logical operators : Here AND(&&), OR(||) are binary operators and NOT(!) is a unary operator. It is used to combine relational operation? and it gives either true(1) or false(O). 

If x=True and y=False then

x && x x && y y && x y && y
True  False False False

Both operands must be true to get a true value in the case of AND(&&) operation 

If x=True and y=False then

x || x x || y y || x y || y
True  False False False

Either one of the operands must be true to get a true value in the case of OR(||) operation If x=True and y=False then

!x !y
False True

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 wilt be executed otherwise the third part will be executed. 

Eg. If x=10 and y=3 then x>y ? cout< Here the output is 10.

6) sizeof( ): This operator is used to find the size used by each data type. Eg. sizeof(int) gives 2. 

7) Increment and decrement

a) Increment operator (++): It is used to increment the value of a variable by one i.e., x++ is equivalent to x=x+1; 

b) Decrement operator (–) : It is used to decrement the value of a variable by one i.e., x-is equivalent to x = x-1.

8) Assignment operator (=) : lt is used to assign the value of a right side to the left side variable.eg. x=5; Here the value 5 is assigned, to the variable x.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...