0% found this document useful (0 votes)
84 views

Comprog 2

This document discusses different types of operators in the C programming language. It describes arithmetic, relational, logical, and bit-wise operators. It also covers increment/decrement operators, conditional operators, and assignment operators. The document provides examples of common operators and their meanings. It discusses operator precedence and provides basic examples of input and output statements in C using printf() and scanf().
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Comprog 2

This document discusses different types of operators in the C programming language. It describes arithmetic, relational, logical, and bit-wise operators. It also covers increment/decrement operators, conditional operators, and assignment operators. The document provides examples of common operators and their meanings. It discusses operator precedence and provides basic examples of input and output statements in C using printf() and scanf().
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Computer Programming

LEARNING C
Operators in C

An operator is a symbol that tells the computer


to perform certain mathematical or logical
manipulations.

Operators are used in program to manipulate


data and variables.
Types of Operators
C Has Four Classes Of Operators
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bit-wise Operators

In Addition, C Has Some Special Operators, Which Are Unique


To C, They Are
1. Increment & Decrement Operators
2. Conditional Operators
3. Assignment Operators
Types of Operators
Arithmetic Operators
Operator Meaning

+ Addition

Subtraction; also for unary minus


_
Multiplication
*
/ Division

% Modulo division (remainder after


integer division)
Types of Operators

Hierarchy of Operators
PRECEDENCE OF OPERATORS (Arithmetic operators only)

Operator Description Associativity


* Multiplication Left to right

/ Division “
% Modulo “
+ Addition “
- Subtraction “
Types of Operators
Relational Operators
 are symbols that are used to test the relationship
between two variables or between a variable and a
constant.
Operator Meaning
> Greater than
>= Greater than or Equal to
< Less than
<= Less than or Equal to
== Equal to
!= Not equal to
Types of Operators
Logical Operators
 Logical Operators are symbols that are used to
combine or negate expressions containing relational
operators.

Operator Meaning
&& Logical AND
|| Logical OR

! Logical NOT
BASIC I/O Statements in C

For ouput:
printf() function
ex. printf(“Enter your age:”);

For input:
scanf() function
ex. scanf(“%d”, &age);
Types of Operators

Assignment Operators

Statement Equivalent Statement


a+=b a=a+b

a-=b a=a-b

a * =b a=a*b

a*=b+c a = a * ( b+ c)

a%=b a=a%b

a*=a a=a*a

You might also like