546 views

Uploaded by Manoj Mallakuntla

paper presentation

- Loop in C
- R Data Science Essentials - Sample Chapter
- Rexx
- Session 3
- Simulation Optimization of Part Input Sequence in a Flexible Manufacturing System.doc
- unit 1fi
- Msx Basic Manual
- ES03 Lab Manual
- There is a Very Important Role Of
- C Quick Guide
- Embedded c Programming Technique
- FSCM Configuration Link
- 55 LUCE Accuracy (SIDT2009)
- PSP Assignment 2 Sp2 2017
- Automatic Image Annotation and Retrieval using Multi-Instance Multi-Label Learning
- Ada-for-the-Cplusplus-or-Java-Developer.pdf
- E PrimeTips
- VB Book.doc
- Capitulo 5
- subtraction algorithm annotated planning template

You are on page 1of 20

LOOPS

Computers are particularly well suited to applications in which operations are repeated many times. If the same task is repeated over and over again a loop can be used to reduce program size and complexity

Algorithm: Step 1: Base 2 Step 2: Product Base Step 3: Product Product * Base Step 4: Product Product * Base Step 5: Product Product * Base Step 6: Print Product

Flowchart

START

Base2

Product Base Product Product * Base Product Product * Base Product Product * Base Print Product

STOP

calculate 2 to the power of 1000? Answer: Use a LOOP (repeated execution of the same set of instructions)

Example 9: Write an algorithm and draw a flowchart to calculate 24 using a loop approach? Verify your result by a trace table.

Algorithm:

Base 2 Power 4 Product Base Counter 1 While Counter < Power Repeat Step 5 through step 7 Step 6: Product Product * Base Step 7: Counter Counter +1 Step 8: Print Product Step 1: Step 2: Step 3: Step 4: Step 5:

START

Base 2 Power 4

Product Base Counter 1

Print Product

STOP

TRACING

BASE POWER PRODUCT COUNTER COUNTER < POWER STEP 1: STEP 2: STEP 3: STEP 4: STEP 5: STEP 6: STEP 7: STEP 5: STEP 6: STEP 7: STEP 5: STEP 6: STEP 7: STEP 5: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ? 4 4 4 4 4 4 4 4 4 4 4 4 4 ? ? 2 2 2 2x2=4 4 4 4x2=8 8 8 8x2=16 16 16 ? ? ? 1 1 1 1+1=2 2 2 2+1=3 3 3 3+1=4 4 ? ? ? T T T T T T T T T F F

Step 1: Base 2 Step 2: Power 4 Step 3: Product Base Step 4: Counter 1 Step 5: While Counter < Power Repeat Step 5 through step 7 Step 6: Product Product * Base Step 7: Counter Counter +1 Step 8: Print Product

STEP 8:

16.

Example 10: Write down an algorithm and draw a flowchart to find and print the largest of three numbers. Read numbers one by one. Verify your result by a trace table. (Use 5, 7, 3 as the numbers read)

Algorithm

Step 5: Step 6:

Step 7:

Input N1 Max N1 Input N2 If (N2>Max) then Max = N2 endif Input N3 If (N3>Max) then Max = N3 endif Print The largest number is:,Max

N1 Step1: Step 2: Step 3: Step 4: Step 5: Step 6: 5 5 5 5 5 5 N2 ? ? 7 7 7 7 N3 ? ? ? ? 3 3 Max N2>Max N3>Max ? 5 5 7 7 7 ? ? T T F F ? ? ? ? F F

START

INPUT N1

MAXN1

INPUT N2

N N2>MAX Y MAXN2

INPUT N3

N N3>MAX Y

MAXN3

STOP

Example 11: Write down an algorithm and draw a flowchart to find and print the largest of N (N can be any number) numbers. Read numbers one by one. Verify your result by a trace table. (Assume N to be 5 and the following set to be the numbers {1 4 2 6 8 })

Algorithm:

Step 6: Step 7: Step 8:

Step 9:

Input N Input Current Max Current Counter 1 While (Counter < N) Repeat steps 5 through 8 Counter Counter + 1 Input Next If (Next > Max) then Max Next endif Print Max

START Input

N, Current

N

Counter < N

Y

Counter Counter +1

Print Max

Input

Next

Tracing

N

Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 5 Step 6 Step 7 Step 8 Step 5 Step 6 Step 7 Step 8 Step 5 Step 6 Step 7 Step 8 Step 5 Step 9 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5

Current

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Max

Counter

Counter < N

Next

1 1 1 1 1 4 4 4 4 4 4 4 4 6 6 6 6 8 8

1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5

T T T T T T T T T T T T T T F F F F

4 4 4 4 2 2 2 2 6 6 6 6 8 8 8

T F F F F F F T T F F T T F

8 output

Prob. 1. Write an algorithm and draw a flowchart to print the square of all numbers from LOW to HIGH. Test with LOW=1 and HIGH=10.

Prob. 2. Write an algorithm and draw a flowchart to print the SUM of numbers from LOW to HIGH. Test with LOW=3 and HIGH=9. Prob. 3. Write an algorithm and draw a flowchart to print the SUM of numbers from LOW to HIGH. Test with LOW=3 and HIGH=9. Prob. 4. Write an algorithm and draw a flowchart to print all numbers between LOW and HIGH that are divisible by NUMBER. Prob. 5. Write an algorithm and draw a flowchart to print all the prime numbers between LOW and HIGH. Test with LOW=1 and HIGH=100.

Prob. 6. Write an algorithm and draw a flowchart to count and print all numbers from LOW to HIGH by steps of STEP. Test with LOW=0 and HIGH=100. Prob. 7. Write an algorithm and draw a flowchart to count and print all numbers from HIGH to LOW by steps of STEP. Test with HIGH=100 and LOW=0. Prob. 8. Write an algorithm and draw a flowchart to print the multiplication table for 6's. i.e. ---- 1 6 = 6 ---- 2 6 = 12 ---- 12 6 = 72

Prob. 9. Write an algorithm and draw a flowchart to print the complete multiplication table for 1's. through 12's.

---- 1 1 = 1, 1 2 = 2, ---- 2 1 = 2, 2 2 = 4, ---- 12 1 = 12, 12 2 = 24, 1 12 = 12 2 12 = 24 12 12 = 144

Prob. 10. Write an algorithm and draw a flowchart to arrange N values read from the input in ascending order. Prob. 11. Write an algorithm and draw a flowchart that will find and print the product of 3 numbers.

Prob. 12. Write an algorithm and draw a flowchart that will find and print The factorial of NUMBER is FACTORIAL. Test the flowchart for NUMBER=5. Prob. 13. Write an algorithm and draw a flowchart that will find and print the number of vowels in a given set of characters and print there number of occurrences.

- Loop in CUploaded byans_h2003
- R Data Science Essentials - Sample ChapterUploaded byPackt Publishing
- RexxUploaded byapi-3729284
- Session 3Uploaded byMohammad Shakib
- Simulation Optimization of Part Input Sequence in a Flexible Manufacturing System.docUploaded byfhichat
- unit 1fiUploaded bySanjeev Malik
- Msx Basic ManualUploaded byelastomania
- ES03 Lab ManualUploaded byJeric Rajal
- There is a Very Important Role OfUploaded byHimanshu Verma
- C Quick GuideUploaded byAlokPSahu
- Embedded c Programming TechniqueUploaded by7272pulkitarora
- FSCM Configuration LinkUploaded bySoumen
- 55 LUCE Accuracy (SIDT2009)Uploaded byguido gentile
- PSP Assignment 2 Sp2 2017Uploaded byKing Everest
- Automatic Image Annotation and Retrieval using Multi-Instance Multi-Label LearningUploaded byBONFRING
- Ada-for-the-Cplusplus-or-Java-Developer.pdfUploaded by3DD4
- E PrimeTipsUploaded byTrầnQuang
- VB Book.docUploaded byseena107
- Capitulo 5Uploaded byAlan Terrazas
- subtraction algorithm annotated planning templateUploaded byapi-400542088
- CCP503Uploaded byapi-3849444
- 2nd EvaluationUploaded byAna Cristina Montillano
- ch09_97Uploaded byVinod Malla
- best lesson planUploaded byapi-398545121
- 1digital System DesignUploaded byharisri269
- Matlab File 2Uploaded byLove Dahiya
- UML 2 Activity Diagram.docxUploaded byJulius
- Scimakelatex.26252.NoneUploaded byGonzalo Gonzales
- 1303Uploaded bygeokaran1579
- 2000 TrainersUploaded byamit62mzn

- _B.tech (CSE) Regulations & Syllabus w.e.f Admitted Batch(2012-13)Uploaded byManoj Mallakuntla
- B.pharmacy -R09 -Regulations SyllabusUploaded byManoj Mallakuntla
- cri-pumpsUploaded byManoj Mallakuntla
- Algo Merge2 TypedUploaded byManoj Mallakuntla
- Lyrics in Telugu_ Sri Rama RajyamUploaded byManoj Mallakuntla
- Job Chart of VROUploaded byManoj Mallakuntla
- 01 Union FindUploaded byprintesoi
- C QuestionsUploaded byramya53919
- Objective Type QuestionsUploaded bysarfzec0381
- edit imageUploaded byManoj Mallakuntla
- Convocation 2014 NamesUploaded byManoj Mallakuntla
- VRO Objective Type Bit Model PaperUploaded byNagesh Kumar
- AP DSC notification 2012Uploaded byVimal Patel
- Cocube Test zUploaded byManoj Mallakuntla
- Getting StartedUploaded byXenogenic Medusa
- 08 Distributed AlgorithmsUploaded byManoj Mallakuntla
- 7.Computer ScienceUploaded byGulzar Islam
- Medical CertificateUploaded byManoj Mallakuntla
- IES Con Comm. 1981Uploaded byRajarshi Pal Chowdhury
- IES CONV Electronic&Comm. 1983Uploaded byManoj Mallakuntla
- IES OBJ Electronics &Telecomm.I 2008Uploaded byManoj Mallakuntla
- IES OBJ Electronics &Telecomm.ii 2007Uploaded byManoj Mallakuntla
- IES OBJ Electronics &Telecomm.ii 2008Uploaded byManoj Mallakuntla
- geethaUploaded byManoj Mallakuntla
- EticketUploaded byManoj Mallakuntla
- North Gate ArinsoUploaded byManoj Mallakuntla
- VCI_Bulletin2010Uploaded byRock Don

- LSPP_eZSetup1Uploaded bywondwosenAyele
- Sweden Telecom GPON FolderUploaded byBinar Candra
- differance between scada plc and dcsUploaded byan7oop
- List of Computer Networking DevicesUploaded bykamit17102900
- SunDriver User Manual V0.1 for WebUploaded byMaikel Dh
- Kinect OpenNI2Uploaded bymemoteto
- contestClassicsEURJPYMCE6.txtUploaded byxxtazzz
- Nais Plc Fp2Uploaded byhieutran86
- Honeywell l5100 Quick Install GuideUploaded byAlarm Grid Home Security and Alarm Monitoring
- Student Enrolment SystemUploaded byDaina Medalla Paculanang
- PwnieExpressUserManual-FixedSensorProductLine (1).pdfUploaded byalexzac
- Jad MakerUploaded byFrancisco Leonel Perez Chogo
- e Elcon Prestige)Uploaded byNitin Goyal
- Proposal UBS Case StudyUploaded byAritra Bhowmik
- FengUploaded byNghĩa Zer
- Samplicity T600 1.3 DocumentationUploaded byarturohj
- Ab Initio Interview QuestionsUploaded byRatika Miglani Malhotra
- IMPLEMENTATION OF FRACTIONAL ORDER TRANSFER FUNCTION USING LOW COST DSPUploaded byIAEME Publication
- 95463256 VM10001 en Rev 1A OM Online ManualUploaded byJackson Dias Rocha
- mellor resumeUploaded byapi-68218861
- Unit 5Uploaded byPauloDoCouto
- Bpmn 2 0 Notation GuideUploaded byannapredin
- GBSS9.0 Troubleshooting Guide(01)Uploaded bysingsanit
- mvc5Uploaded byapi-257280030
- Sample RunUploaded byJudith Thatcher Herrera
- MWS_Getting_Started.pdfUploaded bydakir
- UndocumentedNT.pdfUploaded byShopnoPathik Aion
- Different Learning and Assessment Scenarios Using the CAMPUS Virtual Patient SystemUploaded byeViP Programme
- Yealink CP920 HD IP Conference Phone DatasheetUploaded byWebAntics.com Online Shopping Store
- EVS. Technical Reference XT Hardware Issue3.EnglishUploaded byiscrbdi