0% found this document useful (0 votes)
20 views26 pages

Lecture 3

Uploaded by

BADR ESLAM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views26 pages

Lecture 3

Uploaded by

BADR ESLAM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Programming

Section - 5
Arithmetic operations

2
Arithmetic Operators

3
Examples:

Output

4
Examples:

Output
Examples:

Output
Assignment operations

7
Assignment Operators

8
Examples:
Output

9
Relational operations

10
Relational Operators

11
Examples:

Output
12
Logical operations

13
Logical Operators

14
Scanf()

15
Format specifiers

•The Format specifier is a string used in the formatted input and output
functions. The format string determines the format of the input and
output. The format string always starts with a '%' character.
Data type Format type
int %d or %i It is used to print the signed integer value where signed
integer means that the variable can hold both positive and
negative values.
float %f It is used for printing the decimal floating-point values. By
default, it prints the 6 values after '.'.
char %c It is used to print the unsigned character.
Double %lf it can easily accommodate about 15 to 17 digits after or
before a decimal point. 16
Inputs

• we say INPUT, it means accept some data from user. C


programming provides a set of built-in functions to input the
data on the computer screen.

• scan( ) is used to accept something from screen.

17
Examples:

18
If statement

19
Simple if

20
If-else

21
If-else if- else

22
Task

• Using a C program to design calculator that accept two


numbers from the user & operator (+, -, *, /),
• Then using if to do operation that the user needs

23
Answer:

24
Answer:

25
THANK YOU

You might also like