Technology has advanced to the point where programming has become an essential part of our lives. We use software and applications for communication, entertainment, education, and work, and these are all built on programming languages.

Define operator. Explain different types of operators used in C.

Operator is a special symbol used in programming that performs specific operation on operands. It is used to operate any two or multiple operands. Here,
In c=a+b expression, a, b and c are operands and "=" and "+" are operators.

There are different types of operators used in C programming.
  • Arithmetic operators
  • Relational operators
  • Equality operators
  • Logical operators
  • Assignment operators,
  • Unary operators
  • Conditional operators
  • Size Of operator
Arithmetic Operator
Arithmetic Operators are used to perform mathematical calculations. These operators are used with two or more than two operands. Arithmetic Operators are:
"+"------------------> Addition---------------->a+b---------------->add value of "a" and "b"

"-" ------------------> Subtraction -------------------> a-b-------------> subtract value of "a" and "b"

"*" ---------------------> Multiplication----------------> a*b ---------------> Multiply value of "a" and "b"

"/" -----------------> Division------------------------> a/b ------------------>Divide value of "a" with "b"

"%" ------------------>Modulus -----------------> a%b------------> Takes out Remainder after dividing
                                                                                                      value of "a" with value of "b"

Relational Operator
Relational Operator determines the relationship between two different operands. It is also called comparison operator. This operator is used to check the conditions. Relational Operators are :

"<"  -------------------------------> less than ----------------------> a<b-------> value of a is less than
                                                                                                                       value of b.

">" -------------------------------->greater than -------------------> a>b --------> value of a is greater than
                                                                                                                       value of b.

"<=" --------------> less than or equal to ------------> a<=b ---------->value of a is  less or equal than value of b.

">=" ---------> greater than or equal to------> a>=b ------>value of a is greater or equal than value of b.


Equality Operator

Equality operator compares the value of two operands. Either they may be equal or not.

"==" ------------------> equal to -------------> a==b -------------> value of a is equal to b

"!=" -------------> not equal to -----------> a!=b --------> value of a is not equal to value of b.

Logical Operator
 Logical operator is very important in C programming while creating a logical programs. It connects two or more expressions. It is used to give logical value either true or false.

&& ---------------> Logial AND -------------> (a>b)&&(a>c)

| |  --------------> Logial OR --------------> (a>b)||(a>c)

! --------------> Logical NOT ----------> a!

Assignment Operator
  Assignment operator ("=") is used to assign the value to a variable.
For example
a=2;
 
b=5;

Conditional Operator
Conditional operator is used perform one expression if the given condition is true else performs another expression. It is also known as ternary operator."?" is used as ternary operator.
For example,
expression1?expression2:expression3

expression1 is  evaluated and if it is true than expression2 is evaluated else expression3 is evaluated.

Unary Operator
Unary operators are used to change the value of a variable. It takes only one operand. There are two types of Unary Operator. They are :
Increment Operator
Decrement Operator

Increment Operator
There are two types of Increment operator i.e, Pre-increment operator (++i) :-  Increases value of i before it is utilized, Post-increment operator (i++):-Increases value of i after it is used.

Decrement Operator
There are two types of Decrement operator i.e, pre-decrement operator(--i) :- Decreases value of i before it is utilizedand post-decrement operaor(i++) :- Decreases value of i after it is used.

Share:

No comments:

Post a Comment

If you have any doubt, let me know...

Translate

Wikipedia

Search results