You are on page 1of 14

Online Learning Management System

BACHELOR OF COMMERCE IN COMPUTER APPLICATION

1T4- Programming in c

Faculty - Prof. Kothiram N. Girsawale


(MCM,MBA)
CO 1
Given the problem student can identify and apply the required number of variable ,data type
control statements and will be able to develop a program..

Learning Objectives
• Student will be able to understand operators in c
• Student will be able to use operators in program
• Student will be able to use different types of operators in programming construct
Operators
Operator is a special symbol that tells the
compiler to perform specific mathematical or
logical Operation.
Types of Operators
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Ternary or Conditional Operators
• sizeof operator
Arithmetic operator
Example (int A=8,
Operator B=3) Result

+ A+B 11

- A-B 5

* A*B 24

/ A/B 2

% A%4 0
Relational operator
Example (int A=8,
Operators B=3) Result

< A<B False


<= A<=10 True
> A>B True
>= A<=B False
== A== B False
!= A!=(-4) True
Logical operators
Example (int A=8,
Operator B=3, C=-10) Result

&& (A<B) && (B>C) False

|| (B!=-C) || (A==B) True

! !(B<=-A) True
Truth table of Logical Operator

C1 C2 C1 && C1 || C2 !C1 !C2


C2
T T T T F F
T F F T F T
F T F T T F
F F F F T T
Increment and Decrement operators
• Increment Operators are used to increased the
value of the variable by one and Decrement
Operators are used to decrease the value of the
variable by one in C programs.
• For. Ex.
• a++ increment operator
• a-- decrement operator
Type of Increment Operator

• pre-increment ++a
• post-increment a++
• pre-decrement --a
• post-decrement a--
Assignment operator
Operator Example (int A=8, Result
B=3)

+= A+=B or A=A+B 11
-= A-=3 or A=A+3 5
*= A*=7 or A=A*7 56
/= A/=B or A=A/B 2
%= A%=5 or A=A%5 3
Value of b will be
=a=b
assigned to a
Ternary operator
• If any operator is used on three operands or
variable is known as Ternary Operator. It can
be represented with ? : . It is also called
as conditional operator
• For ex.
• Exp1?exp2:exp3
Sizeof Operator
• The sizeof operator is used to calculate the
size of data type or variables. This operator
returns the size of its variable in bytes.
• For example: sizeof(a), where a is interger, will
return 2.
Thank You

You might also like