Your SlideShare is downloading. ×
0
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Introduction to basic programming repetition
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to basic programming repetition

5,074

Published on

Reviewer Repetition or looping

Reviewer Repetition or looping

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,074
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
92
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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 />

×