0% found this document useful (0 votes)
39 views54 pages

Module Name - Conditionals, Loops & Functions Class - Day 3 Topic Name-Loops

The document is a slide presentation on loops in programming. It includes an agenda that covers while loops, for loops, and do-while loops. Examples are provided of using each loop type to iterate through numbers and check for even or odd values. Pseudocode is also shown for initializing an array using a for loop. The key topics are different types of loops in programming, when to use each type, and examples of their basic syntax and use.

Uploaded by

Vinay Prajapat
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)
39 views54 pages

Module Name - Conditionals, Loops & Functions Class - Day 3 Topic Name-Loops

The document is a slide presentation on loops in programming. It includes an agenda that covers while loops, for loops, and do-while loops. Examples are provided of using each loop type to iterate through numbers and check for even or odd values. Pseudocode is also shown for initializing an array using a for loop. The key topics are different types of loops in programming, when to use each type, and examples of their basic syntax and use.

Uploaded by

Vinay Prajapat
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/ 54

Module Name -

Conditionals, Loops &


Functions
EditEdit
MasterMaster
Class - Day 3
texttext stylesstyles
Topic Name- Loops
Element Slide numbers Maximum time
allowed (min)
Today’s Agenda
Spot Test

Total Time 120




int bricks = 0;
while(bricks < 100) // loop will continue as long as
// this condition is satisfied
{
“Pick up brick”
“Keep it on wall”
bricks = bricks + 1; // value of bricks variable is
} // incremented by 1









Infinite while Loop: Example


for(__;__;__;)
{
code...
}

int i=0 // value of i is 0 initially.


i<10 // Program will be in loop as long as
// this condition remains satisfied


i++ // This will increment the value of i by 1
Check for all numbers between [1 -100]
If even -> Print
Else -> Do not print
Move on to next number
for( int i=1; i<=100; i++ ) {
if( i%2 == 0 )
{
System.out.print( i );
}
}



while Loop for Loop
FOR WHILE
Even Numbers Example using while Loop
Java Code: For Loop



Java Code: For Loop




do{

Code statements…

}
while( condition )
Java Code: Do While Loop



Pseudocode: Array Initialization with For Loop




for( int i= 1; i<3500; i++) {
if(i%2==1) // It means i is odd.
{
continue;
}
System.out.print(i);
}



#LifeKoKaroLift

Thank you!

You might also like