c operators tutorial

Bodhak c operators tutorial in this chapter we will discuss Evan expression, Operator rules, Examples on arithmetic operators, Examples on relational operators, Examples on assignment operator, Examples on unary ++ and — operators, Examples on bitwise operators, Examples on conditional operators.

OPERATORS: C is having very rich built-in operators.  An operator is a symbol that tells the compiler to perform a specific operation.  An operator is a governing body that acts on specific operands to result in the task.

 

 

c operators tutorial:-

. These operators are classified into various types based on their role played at different streams upon these operators are basically classified as following types:

they are Binary Operators. Unary Operators, Ternary Operator

Assignment Operator:

It is used to assign the specific value

of the variable or constant to the given

variable.

“=”

A=10

Name = “Arjun”

i.e  A, Name are Variables. 10 & Arjun are Values

NOTE: The left-hand operand must be a variable.

X*=Y i.e x=x*y

The value of x object is multiplied by the value of y object. The multiplied value of x*y is assigned to x object.

void main()

{

int x=5,y=6;

x*=y;

printf(“%d”, x);

}

The O/P of x is: 30

Logical Operators:

The Operators, which perform the logical instruction in order to justify the multiple conditional linkages, are known as logical operators. C language is supported with the different trait to represent the logical operators.

 

&&  logical and

 

||  logical or

 

!  logical not

Note: This operator are generally used along with conditional statements

Conditional Operator(Ternary Operator):

The operator, which exposes the condition or decision, is known a Conditional Operator. It can also be known as the Ternary operator.

Are they? :

Eg: (a>b)? statement1 : statement2;

If the condition returns true it executes the statement 1, if the condition returns false it executes the statement 2.

Relational Operators:

The operators, which expose the relationship between the specified operands, are known as relational operators. These operators are implemented with decision statements.

>   Greater than

<  Less than

>=  Greater than equal to

<=  Less than equal to

==  equal to

!=  Not equal to

Note : Every relational operator always returns true(1) or false(0)