Operators in c programming.
Operator in c language
C programming supports a rich set of operators. which are a variety of reserved symbols used within an expression to specify the manipulations to be performed when that expression is evaluated. In general, an operator is an operation in c programming. which performs a specific action on the given expression. And there is a huge range of operators available in c programming for special purpose and meanings. You can use these operators as per your requirement.
So in the next part, we will study the different operators of these c programming with examples.
Arithmetic operator in c language – arithmetic operator is a general numerical calculation operator. In arithmetic operators, you get plus, minus, multiplication, division, and mode, operators. These are all default arithmetic operators. Which are used to manipulate arithmetic operations in c programming. With arithmetic operator, we can easily solve any numerical calculation in c programming in programming shape. So let us now look at all these arithmetic operators in detail.
- Arithmetic operator – – +, -, *, /, %
Arithmetic operator | Meaning | Illustration |
+ | Plus/ addition arithmetic operator add two integer numbers. | Int a,b; = a + b |
_ | Minus arithmetic operator. Used to subtract two different integers. | Int a,b; = a – b |
* | Multiplications arithmetic operator. Used to multiplies two different integers. | Int a,b; = a * b |
/ | Division arithmetic operator. Used to divide two different integers. | Int a,b; = a / b |
% | Modulus/remainder arithmetic operator. Used to find modulus between two integers. | Int a,b; = a % b |
Assignment operator in c language – the assignment operator used in c programming is used to assign the value of one already declared programming variable to the value of another variable. With the help of this operator, you can assign default values to one or more variables in c programming to any other variable. Now you assign the same variable value to another declared variable. Use the assignment operator in conjunction with another c operator to accomplish this process. And generate the desired assignment operator output.
- Assignment: – =
- Augmented assignment – +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
Assignment operator | Meaning | Illustration |
= | Assign variable value to another variable. Between two integer variable declare a assign value to b variable. | Int a=5; int b; B=a |
+= | Plus equal .mean plus or equal two variable values in programming. | Int a,b; A+ =b mean a = a+b |
-= | Minus equal . mean minus or equal integer variable values. | Int a,b; A+ =b mean a = a-b |
*= | Multiplication equal . mean multiplies two integer variables values. | Int a,b; A8 =b mean a = a*b |
/= | Division equal . divide two integer operator variable values. | Int a,b; A8 =b mean a = a/b |
%= | Mode equal . mode and equal two different variable values. | Int a,b; A% =b mean a = a%b |
<< = | Left shift assignment operator. left shift memory variable in storage sapce. | Int a,b; A<< =b mean a = a<<b |
>>= | Right shift assignment operator. Right shift memory variable in storage location. | Int a,b; A>> =b mean a = a>>b |
&= | Bit-wise assignment operator bitwise assign variable values. | Int a,b; A& =b mean a = a & b |
^= | Bitwise exclusive or assignment operator assign or used bitwise exclusive or variable values. | Int a,b; A8^=b mean a = a ^ b |
! = | Not equal assignment operator, used to assign not equal variable object. | Int a,b; A!=B mean a = a ! B |
Bitwise logic operator in c language – bitwise operators are used for bit operations in computer memory. Where you do bit-byte level programming. You can perform bitwise and, or, xor, left shift, and right shift memory-related condition logic or operations in programming. This operator is the unary operand.
- Bitwise logic: – ~, &, |, ^
- Bitwise shifts – <<, >>
Bitwise operator | Meaning | Illustration |
~ | Bitwise one’s complement operator | Int a,b ~ a; |
& | Bitwise and operator | Int a,b A&b; |
| | Bitwise or operator | Int a,b A | b; |
^ | Bitwise xor operator | Int a,b A ^ b; |
<< | Bitwise left shift operator | Int a,b A << 4; |
>> | Bitwise right shift operator | Int a,b A >> 4; |
Boolean logic operator in c language – boolean operators are logical operators. These boolean operators are logical and, logical or not logical. These operators are used to test a boolean expression in programming with a true (1) or false (0) value as per the input boolean expressions.
- Boolean logic – ! &&, ||
Bitwise operator | Meaning | Illustration |
! | Logical not bitwise operator | |
&& | Logical and operator | |
|| | Logical or operator |
Conditional evaluation – ? :
Bitwise operator | Meaning | Illustration |
? | Conditional operator |
Equality operator in c language – ==,! =
Equality operator | Meaning | Illustration |
== | Equality operator | |
!= | Not equal operator |
Increment and decrement operator in c language – ++, —
Bitwise operator | Meaning | Illustration |
++ | Increment operator, mean add one in variable value | Int a=5; A++ , ++a |
— | Decrement operator, decrease one in variable values | Int b=3; B–, –b; |
Size of operator in c language – the size of the operator used for the default size of a byte stored by a programming variable declared active in c programming. You can use multiple integers, float, char, string, array, and sizeof operators to check their default stored value or size in memory.
- Object size: – sizeof
Size of operator | Meaning | Illustration |
Sizeof |
Relational operator in c language – relational operator is used to check the relation between two different variable variables relation. As such, they can check for a less than, less or equal relationship, greater than or greater than or equal to, or less than, between two declared operands.
Order relations : – <, <=, >, >=
Relational operator | Meaning | Illustration |
< | Less than relational operator. | |
< = | Less than equal relational operator. | |
> | Greater than relational operator. | |
> = | Greater than equal relational operator. |
Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.