Loops 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Today's agenda

else
if
while loop
loop
for
11 If else
budget 73K Shimla
3K Red
budget fort
false Red
budget a
foot
true

we wantto do something when cond is tone


if Cond is else
and Something else false
if if

Coonan I
if
Il statement I
if condh true Statement1

if condh false statement 2


3
else
I Statement 2
tore
quiet
15777h
if Sop
if
if
elsel
S.o.p else

Quiz 2
int 2 709 false
227031
if
System out pointer
if else

else
System out pointer else
a Read and check number is even or odd
a number
if
divisible 2 remainder is
even no
by g ni 2 so
odd no not divisible by 2

Scanner son new scanner system in


int n Sen neat Intl

4
if ni 2 o

System out pointin even

else h
System out pointin odd
Illogical operator 21 it
and operator 22
22 is
false
dominated Conan I Condh2 Ans
T T T
T T T
T 7 F
F F F

3 Condn

Condnt 22 Condn2 Condn3 answer


T T y F
F F 7 F
T T T T

int 2 50
int
y 393false
n 6021 2074
if y
so.p if if
else I
s op else
08 operator 11
II is true
dominated Conan I Condh2 ans
T T
T
T T
T
T T T
F F
F

3 Condn

Condone I condn2 11 condn3 Answer


T T T T
T T T
T
T T T T
a Read number number is divisible 2003 Point
a
If by
divisible otherwise Point not divisible

Scanner son new scanner system in


int n Sen neat Intl

n 4 divisible

if hi 2 o11 my.z g g neg divisible


System out pointla divisible

else h
system out pointla not divisible 79

pathmark t

marks 905 Enc


G marks 780 good
Caso

marks 370
2 80
avg

mark 560 below


2 50 Avg
Else 1 Else
if if C
enc Statement 1 skip
Conant nan
Ye remaining if else
if
I statement I false check neat conan

A Statement2 skip
else
if condn2
conanz
É remaining if else
statement2
false check rent and

else 3 I
if 4
enc statement3 Skip
11Statement3
am
ye remaining if else
3
false execute else
else f
11Statement4
J
Comparison

true true

I Conant I
if Conant
if
Ilstatements Ilstatement I
3
Icona cononal
if else
if
Ilstatement 2 11Statement 2
3 3
cont elseif condo l
if
Ilstatement 3 th
3
condith elseif condry l
if
muggy Ilstatement y
3

6 Conant Condn3 are true

I t
Statements statement1
Statements
d Man 3 numbers
of
Given 3 numbers Point man out of these

En a b c ans
6 3 4 6
8 3 10 no
12 4 4 12

13 10 13 13
8 6 8 8
11 At It 11

MPsuedo Code
scanner son new Scanner system.in
int a son neat Intl
int b son neat Intl
a b c
int c sch nest Intl 13101in
A 2 b 22 as c

b 22 h a twins
if
a a c

S o p a

be a 22 be c
else b both stains
S
if s
a

o p
C wins
else f
s o p c

3
Break till 9 25PM

I Into to loops
Point all the numbers
from 1 to 5

System out pointer 17


System out pointer 27
system out pointer 37
system out pointer 47
System out pointer 57

point numbers A to 105


from
loop Do similar
thing multiple times
while loop a

loop a
for
dowhiten

Q Point I to 5 using while loop


D controlling variable
int i I
while is 574
System out pointer i
i ith
3
i 8 5 Point
int i t
while 8 574 2 T 2
System out pointer i 3 T 3

Y
site
3 4 T 4
J T 5
6 7

MStructure of white loop

11 initialize loop variable


int i t

2 write while with Cond

while 1 574

3 The Statement you want to sun


System out pointer i

4 UPdation loop variable


of
Quiz 3 9 10

5 T J
int i 5 10 F
while 1071 berit
systemout point i

Quiz 4 i 9 5 Point
T I
int it 3 T 3
while 5 L s F
berit
Systemout point it D
Fitz
3

Quiz 5
int is i i as Point
while i 5 4 1 I
exit
System out point i

itt
3
Quiz 6 i 92 5 Point
int 9 19 I T t
while Cic 5 I 1 T I

System out point i t T I


i n

I s t

II i
I
n

1
Quiz 7
inti O

while ices i 92 5 Point

system out point AlgoPrep 0 T I

i ite I T t

3 2 T O

How times Algoprep will be Printed 3 T e


many
4 T K

5 T I
6 F
Genet

You might also like