Professional Documents
Culture Documents
OPERATORS AND
EXPRESSIONS IN C
• Unary(sizeof,-,++,--,&)
• Binary(+,-,*,/,%),
• Ternary Operators,
operands are a and b in expressions a+b
C by Dr. Deepika Bhatia 4
2. Increment and Decrement Operators
+= a += b a = a+b //a=17
-= a -= b a = a-b //a=7
*= a *= b a = a*b //a=60
/= a /= b a = a/b //a=2 ,12/5=2
%= a %= b a = a%b //a=2 , 12%5
C by Dr. Deepika Bhatia 6
4. Relational operator- there are 06 as below
A relational operator checks the relationship between two
operands.
If the relation is true, it returns 1; if the relation is
false, it returns value 0.
Relational operators are used in decision making and loops.
The logical AND (&&) should not be confused with the bitwise AND
(&) operator. For example:
1 && 4 evaluates to 1 (True && True = True)
while
1 & 4 (0001 & 0100 = 0000) evaluates to 0//bitwise
operator
&& Called Logical AND operator. If both the operands (A && B) is false.
are non-zero, then the condition becomes true.
c1 !c1
F T
T F
#include <stdio.h>
int main()
{
int m = 10, n = 15;
return 0;
}
Ouptut is: n is greater C by Dr. Deepika Bhatia 16
7. BITWISE OPERATOR
Used for manipulating data at bit level Not applied to float or double
C supports a set of bitwise operators for bit manipulation as listed in
Table 3.8. C supports six bit operators. These operators can operate
only on integer operands such as int, char, short, long
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
<< Shift left
>> C by Dr. Deepika Bhatia Shift right 17
The following table lists the Bitwise operators supported by C. Assume
variable 'A' holds 60 and variable 'B' holds 13, then −
X = Y + 10 ;
20 > 90;
a?b:c;
a = 10 + 20 * 30;
; (This is NULL Statement ).
{
int a=10,b=20,c;
c = a + b;
%dDr.n”,c);
printf(“value of C is C: by Deepika Bhatia 31
}
Selection Statements :
Selection Statements are used in decisions making
situations we will look about selections statements in Later
Tutorials. Here is the few examples of Selection statements
•if
•if…else
•Switch
Iterative Statements :
These are also Called as Loops. If we want to Execute a part
of program many times we will use loops.We will going to explain
each and Every loop in Detail in Later Tutorials. Here is the List of
Basic loops in C language.
•for loop.
•while loop.
•do-while loop.
C by Dr. Deepika Bhatia 32
Jump Statements in C