Programming for Problem Solving (3110003)

BE | Semester-1   Winter-2019 | 07-01-2020

Q3) (b)

List out the operators used in C language and explain any three with example.

List of operators used in C language are

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Increment and decrement Operators
  6. Conditional Operators
  7. Bitwise Operators
  8. Special Operators

Relational Operators

Relational Operators are used to compare two numbers and take decisions based on their relation. Relational expressions are used in decision statements such as if, for, while, etc.,  
<   less than
<=   less than or equal to
>   greater than
>=   greater than or equal to
==   is equal to
!=   is not equal to

Logical Operators

Logical operators are used to test more than one condition and make decisions.
&&   logical AND (both conditions are non zero than true, either is zero then false)
| |   logical OR (both conditions are zero then false, either is zero then true)
!   logical NOT (condition is non zero then false, if zero then true)
 

Conditional Operators

A ternary operator is known as a Conditional Operator.
exp1 ? exp2 : exp3    if exp1 is true then execute exp2 otherwise exp3

e.g.
x = (a > b) ? a : b;
which is same as
if( a > b )
        x=a; 
else
        x=b;