Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

6,579 views

6,122 views

6,122 views

Published on

Reviewer Repetition or looping

No Downloads

Total views

6,579

On SlideShare

0

From Embeds

0

Number of Embeds

21

Shares

0

Downloads

94

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Introduction to BASIC Programming<br />RepetitionFlowchart<br />
- 2. Structure<br />Sequence<br />Selection<br />Repetition<br />
- 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. 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. DECISION structure<br />
- 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. 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. Repetition<br />
- 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. 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. Repetition (Post-Test Structure)<br /><ul><li>A post-tested loop executes the body of the loop before testing the termination condition.
- 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. Assignment<br />
- 14. Review for the Long Quiz #3<br />
- 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. 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. 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 />

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment