SlideShare a Scribd company logo
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

04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
04slidemicroemulsions microemulsions microemulsions microemulsions microemuls...
AhmadHashlamon
 
Looping
LoopingLooping
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
JayBhavsar68
 
Loops
LoopsLoops
Loops
Kamran
 
Chapter06.PPT
Chapter06.PPTChapter06.PPT
Chapter06.PPT
vamsiKrishnasai3
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
Shameer Ahmed Koya
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
Ayman Hassan
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)jahanullah
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6Vince Vo
 
Loops in c
Loops in cLoops in c
Loops in c
shubhampandav3
 
06.Loops
06.Loops06.Loops
06.Loops
Intro C# Book
 
While loop
While loopWhile loop
While loop
RabiyaZhexembayeva
 
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
DrDineshenScientist
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
trupti1976
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 

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.ppt
Osama 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 mansour
Osama 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 ghandour
Osama 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 10
Osama 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 ghandour
Osama 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 ghandour
Osama 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 operators
Osama 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 osama
Osama Ghandour Geris
 
Python week 1 2020-2021
Python week 1 2020-2021Python week 1 2020-2021
Python week 1 2020-2021
Osama Ghandour Geris
 
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
Osama 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 ghandour
Osama Ghandour Geris
 
Cooding history
Cooding history Cooding history
Cooding history
Osama Ghandour Geris
 
Computer networks--network
Computer networks--networkComputer networks--network
Computer networks--network
Osama 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 3d
Osama Ghandour Geris
 
Google sketch up-tutorial
Google sketch up-tutorialGoogle sketch up-tutorial
Google sketch up-tutorial
Osama 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 line
Osama Ghandour Geris
 
Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020Design pseudo codeweek 6 2019 -2020
Design pseudo codeweek 6 2019 -2020
Osama Ghandour Geris
 
Php introduction
Php introductionPhp introduction
Php introduction
Osama 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

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

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.