# C Operators Learn the Basics of Programming Step by Step – MPS

C Operators Learn the Basics of Programming Step by Step . In this C programming class, we’ll cowl all supported C operators, clarify their objective with examples.

The operators assist in mathematical and statistical computing. Hence, please learn this tutorial with full focus and focus.

In C programming, we might should carry out many operations on variables like addition, subtraction, division, increment, decrement, and many others. And C language has many built-in operators to hold out such duties. Please see beneath.

Table of Content

## 1. What are C Operators?

The operators are particular symbols that instruct the compiler to carry out a particular operation on the given variable(s).

There are primarily six sorts of operators. Let’s examine them out one by one.

## 2. Types of Operators

### 2.1. Arithmetic Operators

These operators are used to carry out easy arithmetic operations like addition, subtraction, product, quotient, the rest, and many others.

 SYMBOL USAGE + Used so as to add two or extra variables (a+b) – Used to subtract two or extra variables (a-b) * Used to multiply two or extra variables (a*b) / Used to divide two variables (a/b) % Returns the the rest (apercentb) ++ Increments by 1 — Decrements by 1

### 2.2. Relational Operators

These operators are used to examine a relation between two or extra variables like ‘greater than,’ ‘less than,’ and many others. If the end result is optimistic, then the situation will succeed.

The following desk reveals some relational operators supported in C.

 SYMBOL USAGE == Used to examine if the values of two or extra variables are equal. != It exams for the inequality, i.e., not related. > Tests if the left worth is greater than the proper worth. < Tests if the left operand is smaller than the proper one. >= Tests if the left worth is greater than or equal to proper-worth. <= Tests if the left operand is smaller than or equal to the proper one.

### 2.3. Logical Operators

These are used to carry out logical operations.

Here are some logical operators supported in C

 SYMBOL USAGE && The Logical AND operator which checks if a situation is true for each the variables. || Logical OR operator which exams if the situation is true for both of the two variables. ! Logical NOT operator which reverses the logical state of an operand.

### 2.4. Bitwise Operators

These operators are used to carry out operations on binary values.

This desk would enable you.

 SYMBOL USAGE & Used to carry out binary AND operation | Used to carry out binary OR operation ^ Used to carry out binary XOR operation ~ Used to carry out binary complement operation << Used to carry out binary Left Shift operation >> Used to carry out binary Right Shift operation

Now you need to know the binary conversion of a decimal quantity. If not, this instance will enable you.

Let us assume two numbers 3 and 4. Now, in binary format, they’re represented as

``` 8421 //Here each ‘1’ beneath these numbers will add that worth to the quantity

A = 0011 //Hence for 3 it is 0+0+2+1 i.e. 3.

B = 0100 //And for 4 it is 0+1+0+0.

-------

A&B = 0000 //AND operation

A|B = 0111 //OR operation

Complement Operations :

~A = ~3 = 1100 ~B = ~4 = 1011 (Just change 1 by 0 and 0 by 1)

Left Shift and Right Shift operations

A<<1 = 0110 A>>1 = 0001

(Just shift every binary factor to the left or proper by 1)```

### 2.5. Assignment Operators

In C programming, variables get values by utilizing the project operators.

Take an instance, say, if you’ll want to assign the worth “7” to a variable recognized as the “count,” then you’ll be able to do so with the following assertion.

`depend = 7;`

There are two subtypes of the project operators in C programming.

• The easy operator ( = )
• The compound operators (+=, -=, *=, /=, %=, &=, ^=)
 SYMBOL USAGE = depend = 5; Tjhe worth 5 will get assigned to the variable depend. += depend += 5; It means, depend= depend + 5 -= depend -= 5; It means, depend= depend – 5 *= depend *= 5; It means, depend= depend * 5 /= depend /= 5; It means, depend= depend / 5 %= depend %= 5; It means, depend= depend % 5 &= depend &=5; It means, depend= depend & 5 ^= depend ^= 5; It means, depend= depend ^ 5

### 2.6. Miscellaneous Operators

These are some miscellaneous operators.

 SYMBOL USAGE sizeof() Gives the measurement of a variable & Gives the tackle of a variable * Pointer used to level to a variable ?: Used to examine if a particular situation is true.

You might not see any applications or pattern code in this chapter as a result of we’ve got been utilizing these C operators in many of our different tutorials.

Python  Recommended Post:

C Operators Learn the Basics of Programming Step by Step