• Rainy Season
• World
Monday - May 29, 2023

## Operators in C

#### Q) What is an Operator? List operators in C.

• C supports a rich set of built-in operators. An operator is a symbol that tells the computer to perform certain arithmetical or logical manipulation.
• Operators remain applied in programs to manipulate data including variables.
• People usually form a part of this mathematical or logical expression.
 Image Source ~ Crafted With Â©Ishwaranand – 2020 ~ Image by Â©Ishwaranand

#### C operator’s seat does classify within a number of categories. They include:

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
• Arithmetic operators:

#### Q) Explain arithmetic operators.

Arithmetical operators are used to perform arithmetical manipulation like addition, and subtraction.
Following are the Arithmetical operators available in C:
Operator Meaning
Subtraction or unary minus
* Multiplication
/ Division
% Modulo division
void main()
{
int a = 26, b=5P;
Â printf (“/n Addition= % d”, (a+b);
Â printf(“/n substraction =%d”, (a-b);
Â printf(“/n Multiplication = %d”, (a*b);
Â  printf (“/n Division= f”, (float) a/b);
Â printf (“/n Modulus = %d”, (a%b);
getch();
}
Output:
subtraction =21
multiplication = 130
DivisionÂ  = 5.200000
modulusÂ  Â =1
• Relational operators:

#### Q)Explain relational operators in C.

Relational operators are used to compare two or more data items (values) i.e. these operators are used to find the relation of two values. A relational expression is used in decision-making statements like if, while
Supplanting is some relational operators available in C.
Operator Meaning
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal
== Equal to Equal to
!= Not equal to
Example:
Consider a, b, c, d, e and f are integers, then
a = 5 < 10;Â  Â  /*a becomes 1 */
b = 11 <= 10;Â  Â  /*b becomes 0*/
c = 10 >= 20;Â  Â /* c becomes 0*/
d = 10 >= 10;Â  Â  /* d becomes 1*/
e = 20 == 20;Â  Â /*e becomes 1*/
f = 20 != 20;Â  Â  /*f becomes 0*/
• Logical operators:

#### Q) Explain logical operators in C.

C supports three logical operations that are generally performed in real practice.
These operators are used to combine two or more operations together
These are more useful when we want to test multiple conditions simultaneously.
Operator Meaning
&& LogicalÂ AND
|| LogicalÂ OR
! Logical NOT
• Assignment operators:

#### Q) Explain assignment operators in C.

Assignment operators are used to assign the result of an expression to a variable. ‘=’ is the usual assignment operator. C has a set of shorthand assignment operators like +=, *=and so on.=
+=Â  -=Â  Â *= /=Â  %=
Example:
c = a + b; /* Simple assignment */
a = 5; a+=10; /* is similar to a = a + 10; */

Last updated on Sunday - May 21st, 2023

.