Upcoming SlideShare
×

# Introduction to basic programming repetition

6,579 views
6,122 views

Published on

Reviewer Repetition or looping

Published in: Technology, Education
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
6,579
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
94
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Introduction to basic programming repetition

1. 1. Introduction to BASIC Programming<br />RepetitionFlowchart<br />
2. 2. Structure<br />Sequence<br />Selection<br />Repetition<br />
3. 3. SEQUENCE<br />In a computer program or an algorithm, sequence involves simple steps which are to be executed one after the other. <br />
4. 4. Make a Flowchart to add two numbers and print the result.<br />START<br />S=0: n1=0: n2=0<br />n1, n2<br />S= n1+n2<br />Print S<br />STOP<br />
5. 5. DECISION structure<br />
6. 6. SELECTION<br />Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executed<br />
7. 7. Example<br />Compute the sum of x and y if x is greater than y, other wise print d as their difference.<br />Draw a flowchart to find the largest of three numbers A, B, and C.<br />
8. 8. Repetition<br />
9. 9. Repetition<br />Repetition allows for a portion of an algorithm or computer program to be done any number of times dependent on some condition being met. <br />An occurrence of repetition is usually known as a loop.<br />Thebody of the loop is executed repeatedly while the termination condition is true.<br />
10. 10. Repetition (Pre-Test Structure)<br />A pre-tested loop is so named because the condition has to be met atthe very beginning of the loop. <br />This construct is often called a guarded loop. <br />
11. 11. Repetition (Post-Test Structure)<br /><ul><li>A post-tested loop executes the body of the loop before testing the termination condition.
12. 12. This construct is often referred to as an unguarded loop. </li></li></ul><li>Variables (in memory):<br />Num [ 4 ]<br />Result [ ]<br />Count [ ]<br />Input:<br />Num <- 4<br />Enter a Number => 4<br />Count = 4<br />4 > 0 ? => YES<br />Count = 3<br />3 > 0 ? => YES<br />Count = 2<br />2 > 0 ? => YES<br />Count = 1<br />1 > 0 ? => YES<br />Count = 0<br />0 > 0 ? => NO<br />Example: <br />What is the output of the following flowchart when the input is Num= 4<br />Variables (in memory):<br />Num [ 4 ]<br />Result [ 0 ]<br />Count [ 4 ]<br />Variables (in memory):<br />Num [ 4 ]<br />Result [ 7 ] 4 + 3<br />Count [ 2 ] 3 - 1<br />Variables (in memory):<br />Num [ 4 ]<br />Result [ 9 ] 7 + 2<br />Count [ 1 ] 2 - 1<br />Variables (in memory):<br />Num [ ]<br />Result [ ]<br />Count [ ]<br />Variables (in memory):<br />Num [ 4 ]<br />Result [ 10] 9 + 1<br />Count [ 0 ] 1 - 1<br />Variables (in memory):<br />Num [ 4 ]<br />Result [ 4 ] 0 + 4<br />Count [ 3 ] 4 - 1<br />Count: 4<br />Count: 3<br />Count: 2<br />Count: 1<br />Count: 0<br />Result: 10<br />
13. 13. Assignment<br />
14. 14. Review for the Long Quiz #3<br />
15. 15. Selection (Structure)<br />Determine if the input age is qualified to vote or not. If qualified, display “Qualified to vote!” if not, display “Too young!”<br />Given a number, print the message “Positive”, “Negative” or “Neither”<br />
16. 16. 3. The V. Mapa High School is accepting freshmen who are not more than 15 years old. Given the students’ name and age, print “ACCEPTED” if it meets the ages Requirement otherwise print “Sorry”<br />
17. 17. 4. Due to your poor results in the examination, I decided to increase each one of you by 5 points. Input your grade and print the new grade. If the original grade exceeds 90, then it remains as is.<br />