Category

## C Programming Operators and Expressions

The sign that is used to complete logical & mathematical operations in c programs is called an operator. consider the expression A+B*10 inside +,*. are operators, A, B are variables, and 10 is constant. and A+B*10 is an expression. There are different types of operators in c which are below.

## Types of operators in C Programming

There are different types of operators in c language which are as follows.

• Arithmetic operators
• Relational operators
• Logical operators
• Assignment operators
• Increment and Decrement operators
• Conditional operators
• Bitwise operators
• Special operators

### Arithmetic operators

An arithmetic operator is a mathematical function that takes two operands and performs a calculation on them for taking the result. Arithmetic operators are used in common and most computer languages contain a set of operators that can be used within the equations to execute a number of types of sequential calculations.
Operator Description of operators Example
+ Adds two  or more operands A + B+C = 30
Used to subtract operands. B − C= -10
* Multiplies operands. A B C = 200
/ Divides numerator by de-numerator. A / B = 2
% Remainder or Modules Operator of after an integer division. B % A = 0
++ The incremental operator increases the integer value by one. A++ = 11
-- The decrement operator decreases the integer value by one. A-- = 9

### Relational operators

A relational operator compares the two values quantitatively. Using the Relational Operator segment In C Programming we can compare the value stored between two variables and depending on the result we can follow different blocks using Relational Operator in C language.

## Bitwise Operators

The bitwise operator works on bits and performs the bit-by-bit operation. The truth tables for &, |, and ^ is as follows −

p q p & q p | q p ^ q
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1

### increment/decrements operators

The increment operators are unary operators that add or subtract one represented by a (++) sign. The increment operator is used to increase the value by one, on the other side the Decrements operator is used to decrease the value of the variable by one  (1)the decrements operator is denoted by –.

### logical operators

The idea of the logical operators is very simple. The permission for the program to make a decision based on multiple conditions either true or false. Every operand is considered a condition that can be evaluated to a true or false value. There are three types of logical operators in c these are   (OR), && (AND),! (NOT)  they are called.

Operator Description Example
&& If both operands are non-zero, then the condition becomes true. It is called logical and operator (B && C) is false.
|| If any of the two operands is non-zero, then the condition becomes true. It is called logical or operator (AB|| C) is true.
! It is used to reverse the logical state of its operand. If a condition is true, then the Logical NOT operator will make it false. !(B && C) is true.

### conditional operators

The  Conditional operators return one value if the condition is true and returns false if the condition is false. There are three conditional operators in c these operators tell the compiler to perform specific mathematical functions. C language is rich in built-in operators and provides the following types of operators − Arithmetic Operators. Relational Operators. Logical Operators.

### Assignment operator

The assignment operator is used to give a new value to a variable, Assignment operators can also be used for logical operations such as bitwise logical operations.

## Operators' Precedence in C

Operator precedence determines how an expression is evaluated which operator will work first and which will work last. Seom operators have higher precedence than others; for example, the multiplication operator has higher precedence than the others.

Show Examples