0% found this document useful (0 votes)
21 views12 pages

Welcome To Sowmya Tutorials: Bca 1St Semester - Nep - Introduction To C Programming

The document provides an introduction to operators and expressions in C programming, detailing various types of operators including arithmetic, relational, logical, assignment, and others. It explains the functionality of each operator with examples and return values, emphasizing their use in mathematical operations and decision-making processes. Additionally, it covers compound assignment operators that allow for more concise variable assignments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Welcome To Sowmya Tutorials: Bca 1St Semester - Nep - Introduction To C Programming

The document provides an introduction to operators and expressions in C programming, detailing various types of operators including arithmetic, relational, logical, assignment, and others. It explains the functionality of each operator with examples and return values, emphasizing their use in mathematical operations and decision-making processes. Additionally, it covers compound assignment operators that allow for more concise variable assignments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

WELCOME TO SOWMYA TUTORIALS

CLASS: BCA 1st SEMESTER | NEP|

INTRODUCTION TO C PROGRAMMING| L5

CHAPTER 2: OPERATORS AND EXPRESSIONS


Operators

An operator is a Symbol that performs an operation.

An operator acts some variables are called operands to get the


desired result.

Ex : a+b; Where a, b are operands and + is the operator.


Types of Operator
1) Arithmetic Operators.

2) Relational Operators.

3) Logical Operators.

4) Assignment Operators.

5). Unary Operators.

6) Conditional Operators.

7) Special Operators.

8) Bitwise Operators.

9) Shift Operators.
Arithmetic Operators

An arithmetic operator performs mathematical operations such as addition, subtraction and


multiplication on numerical values (constants and variables).

OPERATOR DESCRIPTION
+ ADDITION
- SUBTRACTION
* MULTIPLICATION
/ DIVISION
% MODULAS
Relational Operators.

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. Operands may be variables, constants or expressions.

Relational operators are used in decision making and loops.

Operator Meaning Example Return value

< is less than 2< 9 1

<= is less than or equal to 2<=2 1

> is greater than 2 > 9 0

>= is greater than or equal to 3>=2 1

== is equal to 2==3 0

!= is not equal to 2!=2 0


Logical Operators

These operators are used to combine the results of two or more conditions.

An expression containing logical operator returns either 0 or 1 depending upon whether


expression results true or false.

Logical operators are commonly used in decision making in C programming.

Operator Meaning Example Return value

&& Logical AND (9>2)&&(17>2) 1

|| Logical OR (9>2) || (17 = = 7) 1

! Logical NOT 29!=29 0


Logical AND : If any one condition false the complete condition becomes false.

Truth Table

Op1 Op2 Op1 && Op2

false(0) false(0) false(0)

false(0) true(1) false(0)

true(1) false(0) false(0)

true(1) true(1) true(1)


Logical OR : If any one condition true the complete condition becomes true.

Truth Table

Op1 Op2 Op1 || Op2

false(0) false(0) false(0)

false(0) true(0) true (1)

true(1) false(0) true (1)

true(1) true(1) true(1)


Logical Not : This operator reverses the value of the expression it operates on i.e, it
makes a true expression false and false expression true.

truth table

Op1 Op1 !

false(0) true (1)

true(1) false (0)


Assignment Operators

Assignment operators are used to assign a value (or) an expression (or) a


value of a variable to another variable.

Syntax : variable name=expression (or) value (or) variable


Ex : x=10;
y=a+b;
z=p;
Compound assignment operator
‘C’ provides compound assignment operators to assign a value to variable in order
to assign a new value to a variable after performing a specified operation.

Operator Example Meaning

+= x+=y x=x+y

-= x-=y x=x-y

*= x*=y x=x*y

/= x/=y x=x/y

%= x%=y X=x%y
THANK YOU
If you like my videos please do subscribe
and click on the bell icon for the
notification of the new videos.

You might also like