Types of Operator in C Programming Notes

In C programming there are several operators are there those are, arithmetic operator, assignment, increment , decrement, logical, conditional, comma, size of , bitwise and others. So get all types of operator in C Programming notes in simple and understandable words.

An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations.

In this article, I will be sharing different types of Operator in C Programming Notes.


Types of Operators in C Language

An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations. 

C operators can be classified as

1. Arithmetic operators

2. Relational operators

3. Logical operators

4. Assignment operators

5. Increment or Decrement operators

6. Conditional operator

7. Bit wise operators

8. Special operators


Increment and Decrement operators in C

The Unary operator ++, --, is used as increment and decrement which acts upon single operand. Increment operator increases the value of variable by one. Similarly decrement operator decrease the value of the variable by one. And these operator can only used with the variable, but cann't use with expression and constant as ++6 or ++(x+y+z).

It again categories into prefix post fix . In the prefix the value of the variable is

incremented 1st, then the new value is used, where as in postfix the operator is

written after the operand(such as m++,m--).

EXAMPLE

let y=12;

z= ++y;

y= y+1;

z= y;

Similarly in the postfix increment and decrement operator is used in the operation .And then increment and decrement is perform.

Similarly in the postfix increment and decrement operator is used in the operation. And then increment and decrement is perform.

EXAMPLE

let x= 5;

y= x++;

y=x;

x= x+1;

CONDITIONAL OPERATOR in C 


A ternary operator pair "?:" is available in C to construct conditional expressions of the form.

exp1 ? exp2 : exp3;

It work as if exp1 is true then exp2 else exp3 


It sometimes called as ternary operator. Since it required three expressions as operand and it is represented as (? , :).

SYNTAX

exp1 ? exp2 :exp3

Here exp1 is first evaluated. It is true then value return will be exp2 . If false then exp3.


BIT WISE OPERATORS in C Programming

C supports special operators known as bit wise operators for manipulation of data at bit level. They are not applied to float or double.

Bitwise operator permit programmer to access and manipulate of data at bit level. 

Various bitwise operator enlisted are

  • one's complement (~)
  • bitwise AND (&)
  • bitwise OR (|)
  •  bitwise XOR (^)
  • left shift (<<)
  • right shift (>>)

These operator can operate on integer and character value but not on float and double. In bitwise operator the function showbits( ) function is used to display the binary representation of any integer or character value. 

In one's complement all 0 changes to 1 and all 1 changes to 0. In the bitwise OR its value would obtaining by 0 to 2 bits.

As the bitwise OR operator is used to set on a particular bit in a number. Bitwise AND the logical AND.
It operate on 2operands and operands are compared on bit by bit basic. 

And hence both the operands are of same type. 

SPECIAL OPERATORS in C


These operators which do not fit in any of the above classification are ,(comma), sizeof, Pointer operators(& and *) and member selection operators (. and ->). The comma operator is used to link related expressions together.
sizeof operator is used to know the sizeof operand.


To know rest of operator detail visit: Operator in C programming


Want to Know more So Checkout more such Knowledgeable Article and Comment below for any Queries and more.

Check more posts on Programming and Information related to Coding only at Copy2Run Programs

Thanks for Visiting – Stay Updated with our Site and keep Visiting.

Comments

Popular posts from this blog

Implement Bouncing Ball Animation Using C Graphics

Walking Stickman -Using C graphics

Sine Wave - Using C Graphics