SlideShare a Scribd company logo
1 of 45
Agenda
1- Warm up Listen to this video about motivating
programmers 5 min
2- ppt teacher demonstrate about loops 20 min
3- Video about how we can use c programming in rea
life projects , automation and solving problems 3 min
4-Students play or act a game about simulating loops
10 min
5- practical work using lap tops through code blocks i
implement a small program work in pairs 10 min
6- use netacade.com to self learn C and get certificate
from CISCO 5 min
7- Questions and answers 20 min
8-Refelection 5 min
9- Home work
LO CS.2.02 - Design
programs involving
decision structures
and loops.
Lesson plan
Warm Up
Listen to this video
motivating programmers
Open Code blocks or
www.Jdoodle.com on
line
Essential Question
1- why we use computers ?
2- what are the tasks , jobs
which can be computerized ?
3- what are Repetitions or loops
4- Distinguish between
while and do while and for
loop
Warm Up
Listen to this video
Off line
On line
Essential Question
How to Perform certain
repetitive tasks , control
all loops by sequence
statements?
7
–While
–Do while
–For
Repetition Statements /
Loops
8
Repetition Statements
• Repetition statements allow us to
execute a statement or a block of
statements multiple times
• Like conditional statements, they are
controlled by boolean expressions
• C has three kinds of repetition
statements:
while
Do while
for
Types of Loops
• Pretest - a logical condition is checked
before each repetition to determine if
the loop should terminate
–while loop
–for loop
• Posttest - a logical condition is
checked after each repetition for
termination
–do-while loop
PreTest vs. PostTest Loops
Pretest Loop
Condition
Action or
Actions
true
f alse
Posttest Loop
Condition
Action or
Actions
true
f alse
11
The while Statement
• A while statement has the following syntax:
• If the condition is true, the statement is
executed
• Then the condition is evaluated again, and if it is
still true, the statement is executed again
• The statement is executed repeatedly until the
condition becomes false
while ( condition )
statement;
Logic of a while Loop
statement
true false
condition
evaluated
5
13
The while Statement
• An example of a while statement:
• If the condition of a while loop is false
initially, the statement is never executed
• Therefore, the body of a while loop will
execute zero or more times
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Trace while Loop
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Initialize count
animation
7
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
(count < 2) is true
animation
8
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Print Welcome to Java
animation
9
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Increase count by 1
count is 1 now
animation
10
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
(count < 2) is still true since count
is 1
animation
11
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Print Welcome to C programming
animation
12
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
Increase count by 1
count is 2 now
animation
13
Trace while Loop, cont.
int count = 0;
while (count < 2)
{
printf("Welcome to C programming!");
count++;
}
(count < 2) is false since count is 2
now
animation
14
Trace while Loop
int count = 0;
while (count < 2)
{
System.out.println("Welcome to Java!");
count++;
}
The loop exits. Execute the next
statement after the loop.
animation
15
Posttest Loop: Do-While
Syntax:
do {
statement(s)
} while (condition);
Corresponds to:
statement
if (!condition) DONE
statement
if (!condition) DONE
...
condition
statement(s)
true
f alse
Using the Do-While
do {
printf(“Enter id# and salary: “);
scanf(“%d %f”,&id,&salary);
printf(“You entered id#%1d and salary
$%.2f, Is this correct? (Y/N) “
,id,salary);
scanf(“ %c”,&ans);
} while (!((ans == ‘Y’) || (ans == ‘y’)));
• Loop always executes at least once
While vs Do-While
• Differences
–where condition tested:
• while (first) - may execute 0 times
• do-while (last) - must execute at least one
time
• Similarities
–one statement executed
–initialization before loop
–update during loop
Pretest Loop: For
• Initialization included in loop header
• Update included in loop header
• Header also includes update
• Syntax:
for ( init ; condition ; update )
statement;
• Generally for loops expected to
execute fixed number of times
(counter-controlled)
For Loop
• Syntax:
for ( init ;
condition ;
update )
statement;
• Init: assignments to
counter variables
• Update: changes to
counter variables
Condition
Statement
true
f alse
Init
Update
For Example
• Printing vertical line
of stars:
for (counter = 0;
counter < 5;
counter++)
printf(“*n”);
counter < 5
printf ("*n");
true
f alse
counter = 0;
counter++;
For Example - Sum of 1 to N
printf(“Number to sum to: “);
scanf(“%d”,&N);
total = 0;
for (I = 1; I <= N; I++)
total += I;
/* total is now 1 + 2 + … + N */
Are we ready to code it?
http://www.stemassiut.info prepared By Mr. Osama Ghandour
30
Game about simulating loops
31
Game about simulating loops
32
For Example - Max of N Scores
printf(“Number of students: “);
scanf(“%d”,&NumStudents);
for (I = 0; I < NumStudents; I++) {
printf(“Enter student score %d: “);
scanf(“%d”,&score);
if (score > max)
max = score;
}
/* max is highest score entered */
Listen to this video
about programming
Arduino
Off line
On line
Directions of Counting
for (I = 10; I >= 1; I--)
printf(“%d…n”,I);
printf(“0 BLASTOFF!n”);
printf(“Enter start, end, inc values: “);
scanf(“%d%d%d”,&lstart,&lend,&linc);
for (I = lstart;
((linc < 0) && (I < lend)) ||
((linc > 0) && (I > lend));
I += linc)
printf(“%dn”,I);
practical work using lap
tops through code blocks
in implement a C small
program work in pairs 20
min
Use netacade.com to self
learn C and get certificate
from CISCO 7 7 min
Online auto answered
quiz 15 min
39
–While
–Do while
–For
Repetition Statements / Loops
Types of loops :
Summary
Reflection
• What is your goal to accomplish in
next week End Using loops in C
programming Language ?
students create in small
groups a c program
related to their capstone
project .
Home work
+ =
C program
Arduino
Arduino hardware
controller
components of irradiation
system
Home Work
Discuss how to use
Loops in coding
different programs
in a video by using
office mix. 43
Resources
• watch a video that explain different ways
for loops and read in the following links :
https://www.youtube.com/watch?v=Rtww8
3GH0BU
44
Thanks
Mr. Osama Ghandour

More Related Content

Similar to Week2 ch4 part1edited 2020

Similar to Week2 ch4 part1edited 2020 (20)

04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
 
Introduction to c part -1
Introduction to c   part -1Introduction to c   part -1
Introduction to c part -1
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
 
Looping
LoopingLooping
Looping
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
Ch5(loops)
Ch5(loops)Ch5(loops)
Ch5(loops)
 
Loops
LoopsLoops
Loops
 
Chapter06.PPT
Chapter06.PPTChapter06.PPT
Chapter06.PPT
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Loops in c
Loops in cLoops in c
Loops in c
 
06.Loops
06.Loops06.Loops
06.Loops
 
While loop
While loopWhile loop
While loop
 
Workbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdfWorkbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdf
 
ICP - Lecture 9
ICP - Lecture 9ICP - Lecture 9
ICP - Lecture 9
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
 
Loops c++
Loops c++Loops c++
Loops c++
 

More from Osama Ghandour Geris

functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...Osama Ghandour Geris
 
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.ppt
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.pptPython week 5 2019-2020 for G10 by Eng.Osama Ghandour.ppt
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.pptOsama Ghandour Geris
 
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansourPython cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansourOsama Ghandour Geris
 
Python cs.1.12 week 9 10 2020-2021 covid 19 for g10 by eng.osama ghandour
Python cs.1.12 week 9 10  2020-2021 covid 19 for g10 by eng.osama ghandourPython cs.1.12 week 9 10  2020-2021 covid 19 for g10 by eng.osama ghandour
Python cs.1.12 week 9 10 2020-2021 covid 19 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Python week 7 8 2019-2020 for grade 10
Python week 7 8 2019-2020 for grade 10Python week 7 8 2019-2020 for grade 10
Python week 7 8 2019-2020 for grade 10Osama Ghandour Geris
 
Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10 Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10 Osama Ghandour Geris
 
Python week 5 2019 2020 for g10 by eng.osama ghandour
Python week 5 2019 2020 for g10 by eng.osama ghandourPython week 5 2019 2020 for g10 by eng.osama ghandour
Python week 5 2019 2020 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Python week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandourPython week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Programming intro variables constants - arithmetic and assignment operators
Programming intro variables   constants - arithmetic and assignment operatorsProgramming intro variables   constants - arithmetic and assignment operators
Programming intro variables constants - arithmetic and assignment operatorsOsama Ghandour Geris
 
Mobile appliaction w android week 1 by osama
Mobile appliaction w android week 1 by osamaMobile appliaction w android week 1 by osama
Mobile appliaction w android week 1 by osamaOsama Ghandour Geris
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourOsama Ghandour Geris
 
How to print a sketch up drawing in 3d
How to print a sketch up drawing  in 3dHow to print a sketch up drawing  in 3d
How to print a sketch up drawing in 3dOsama Ghandour Geris
 
7 types of presentation styles on line
7 types of presentation styles on line7 types of presentation styles on line
7 types of presentation styles on lineOsama Ghandour Geris
 
Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020Osama Ghandour Geris
 

More from Osama Ghandour Geris (20)

functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
 
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.ppt
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.pptPython week 5 2019-2020 for G10 by Eng.Osama Ghandour.ppt
Python week 5 2019-2020 for G10 by Eng.Osama Ghandour.ppt
 
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansourPython cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
 
Python cs.1.12 week 9 10 2020-2021 covid 19 for g10 by eng.osama ghandour
Python cs.1.12 week 9 10  2020-2021 covid 19 for g10 by eng.osama ghandourPython cs.1.12 week 9 10  2020-2021 covid 19 for g10 by eng.osama ghandour
Python cs.1.12 week 9 10 2020-2021 covid 19 for g10 by eng.osama ghandour
 
Python week 7 8 2019-2020 for grade 10
Python week 7 8 2019-2020 for grade 10Python week 7 8 2019-2020 for grade 10
Python week 7 8 2019-2020 for grade 10
 
Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10 Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10
 
Python week 5 2019 2020 for g10 by eng.osama ghandour
Python week 5 2019 2020 for g10 by eng.osama ghandourPython week 5 2019 2020 for g10 by eng.osama ghandour
Python week 5 2019 2020 for g10 by eng.osama ghandour
 
Python week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandourPython week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandour
 
Programming intro variables constants - arithmetic and assignment operators
Programming intro variables   constants - arithmetic and assignment operatorsProgramming intro variables   constants - arithmetic and assignment operators
Programming intro variables constants - arithmetic and assignment operators
 
Mobile appliaction w android week 1 by osama
Mobile appliaction w android week 1 by osamaMobile appliaction w android week 1 by osama
Mobile appliaction w android week 1 by osama
 
Python week 1 2020-2021
Python week 1 2020-2021Python week 1 2020-2021
Python week 1 2020-2021
 
6 css week12 2020 2021 for g10
6 css week12 2020 2021 for g106 css week12 2020 2021 for g10
6 css week12 2020 2021 for g10
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandour
 
Cooding history
Cooding history Cooding history
Cooding history
 
Computer networks--network
Computer networks--networkComputer networks--network
Computer networks--network
 
How to print a sketch up drawing in 3d
How to print a sketch up drawing  in 3dHow to print a sketch up drawing  in 3d
How to print a sketch up drawing in 3d
 
Google sketch up-tutorial
Google sketch up-tutorialGoogle sketch up-tutorial
Google sketch up-tutorial
 
7 types of presentation styles on line
7 types of presentation styles on line7 types of presentation styles on line
7 types of presentation styles on line
 
Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020
 
Php introduction
Php introductionPhp introduction
Php introduction
 

Recently uploaded

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 

Recently uploaded (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 

Week2 ch4 part1edited 2020

  • 1. Agenda 1- Warm up Listen to this video about motivating programmers 5 min 2- ppt teacher demonstrate about loops 20 min 3- Video about how we can use c programming in rea life projects , automation and solving problems 3 min 4-Students play or act a game about simulating loops 10 min 5- practical work using lap tops through code blocks i implement a small program work in pairs 10 min 6- use netacade.com to self learn C and get certificate from CISCO 5 min 7- Questions and answers 20 min 8-Refelection 5 min 9- Home work
  • 2. LO CS.2.02 - Design programs involving decision structures and loops. Lesson plan
  • 3. Warm Up Listen to this video motivating programmers Open Code blocks or www.Jdoodle.com on line
  • 4. Essential Question 1- why we use computers ? 2- what are the tasks , jobs which can be computerized ? 3- what are Repetitions or loops 4- Distinguish between while and do while and for loop
  • 5. Warm Up Listen to this video Off line On line
  • 6. Essential Question How to Perform certain repetitive tasks , control all loops by sequence statements?
  • 8. 8 Repetition Statements • Repetition statements allow us to execute a statement or a block of statements multiple times • Like conditional statements, they are controlled by boolean expressions • C has three kinds of repetition statements: while Do while for
  • 9. Types of Loops • Pretest - a logical condition is checked before each repetition to determine if the loop should terminate –while loop –for loop • Posttest - a logical condition is checked after each repetition for termination –do-while loop
  • 10. PreTest vs. PostTest Loops Pretest Loop Condition Action or Actions true f alse Posttest Loop Condition Action or Actions true f alse
  • 11. 11 The while Statement • A while statement has the following syntax: • If the condition is true, the statement is executed • Then the condition is evaluated again, and if it is still true, the statement is executed again • The statement is executed repeatedly until the condition becomes false while ( condition ) statement;
  • 12. Logic of a while Loop statement true false condition evaluated 5
  • 13. 13 The while Statement • An example of a while statement: • If the condition of a while loop is false initially, the statement is never executed • Therefore, the body of a while loop will execute zero or more times int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; }
  • 14. Trace while Loop int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } Initialize count animation 7
  • 15. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } (count < 2) is true animation 8
  • 16. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } Print Welcome to Java animation 9
  • 17. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } Increase count by 1 count is 1 now animation 10
  • 18. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } (count < 2) is still true since count is 1 animation 11
  • 19. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } Print Welcome to C programming animation 12
  • 20. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } Increase count by 1 count is 2 now animation 13
  • 21. Trace while Loop, cont. int count = 0; while (count < 2) { printf("Welcome to C programming!"); count++; } (count < 2) is false since count is 2 now animation 14
  • 22. Trace while Loop int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } The loop exits. Execute the next statement after the loop. animation 15
  • 23. Posttest Loop: Do-While Syntax: do { statement(s) } while (condition); Corresponds to: statement if (!condition) DONE statement if (!condition) DONE ... condition statement(s) true f alse
  • 24. Using the Do-While do { printf(“Enter id# and salary: “); scanf(“%d %f”,&id,&salary); printf(“You entered id#%1d and salary $%.2f, Is this correct? (Y/N) “ ,id,salary); scanf(“ %c”,&ans); } while (!((ans == ‘Y’) || (ans == ‘y’))); • Loop always executes at least once
  • 25. While vs Do-While • Differences –where condition tested: • while (first) - may execute 0 times • do-while (last) - must execute at least one time • Similarities –one statement executed –initialization before loop –update during loop
  • 26. Pretest Loop: For • Initialization included in loop header • Update included in loop header • Header also includes update • Syntax: for ( init ; condition ; update ) statement; • Generally for loops expected to execute fixed number of times (counter-controlled)
  • 27. For Loop • Syntax: for ( init ; condition ; update ) statement; • Init: assignments to counter variables • Update: changes to counter variables Condition Statement true f alse Init Update
  • 28. For Example • Printing vertical line of stars: for (counter = 0; counter < 5; counter++) printf(“*n”); counter < 5 printf ("*n"); true f alse counter = 0; counter++;
  • 29. For Example - Sum of 1 to N printf(“Number to sum to: “); scanf(“%d”,&N); total = 0; for (I = 1; I <= N; I++) total += I; /* total is now 1 + 2 + … + N */
  • 30. Are we ready to code it? http://www.stemassiut.info prepared By Mr. Osama Ghandour 30
  • 33. For Example - Max of N Scores printf(“Number of students: “); scanf(“%d”,&NumStudents); for (I = 0; I < NumStudents; I++) { printf(“Enter student score %d: “); scanf(“%d”,&score); if (score > max) max = score; } /* max is highest score entered */
  • 34. Listen to this video about programming Arduino Off line On line
  • 35. Directions of Counting for (I = 10; I >= 1; I--) printf(“%d…n”,I); printf(“0 BLASTOFF!n”); printf(“Enter start, end, inc values: “); scanf(“%d%d%d”,&lstart,&lend,&linc); for (I = lstart; ((linc < 0) && (I < lend)) || ((linc > 0) && (I > lend)); I += linc) printf(“%dn”,I);
  • 36. practical work using lap tops through code blocks in implement a C small program work in pairs 20 min
  • 37. Use netacade.com to self learn C and get certificate from CISCO 7 7 min
  • 39. 39 –While –Do while –For Repetition Statements / Loops Types of loops : Summary
  • 40. Reflection • What is your goal to accomplish in next week End Using loops in C programming Language ?
  • 41.
  • 42. students create in small groups a c program related to their capstone project . Home work + = C program Arduino Arduino hardware controller components of irradiation system
  • 43. Home Work Discuss how to use Loops in coding different programs in a video by using office mix. 43
  • 44. Resources • watch a video that explain different ways for loops and read in the following links : https://www.youtube.com/watch?v=Rtww8 3GH0BU 44

Editor's Notes

  1. But don’t hide behind your slides.
  2. And practice, practice, practice.