0% found this document useful (0 votes)
3 views8 pages

Algorithm & Flowchart

The document discusses the differences between algorithms and flowcharts, highlighting their respective roles in programming and problem-solving. It outlines various programming concepts such as mathematical and relational operators, control statements, and provides examples of algorithms and flowcharts for tasks like swapping numbers and finding the largest of three numbers. Additionally, it includes pseudocode examples and explanations of control flow statements like 'do while' loops.

Uploaded by

vishiattitude18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Algorithm & Flowchart

The document discusses the differences between algorithms and flowcharts, highlighting their respective roles in programming and problem-solving. It outlines various programming concepts such as mathematical and relational operators, control statements, and provides examples of algorithms and flowcharts for tasks like swapping numbers and finding the largest of three numbers. Additionally, it includes pseudocode examples and explanations of control flow statements like 'do while' loops.

Uploaded by

vishiattitude18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
upiifem ah octet & dt aie (Difference between Algorithm and Flowchart) Stenfein i, fasett sit enrear % aerate at ved veer Sea ere fae rar & Foret oa eer aera fore sepefirs wow ert fi sine ft afar & fore, utes at eat freefera Paar var & it Fs ectrened itt egrets @ ue seirard at aah # fairer tat var seer fer saver & St wevitfeen at area Heras aera 8 | woifeen atte setrard ea ere & at vee eid ite Re sara a & smile ee cere arr aes et mech aver eter 8, aedifas ae sie at ere at aa azar th Uetifen ft afew vem a8 is ae fret vf area st ee & areata ¢ saat ect ar wean 8, Sfea ae Sa ane aecat 8 Paaht aren at eet ee 8 vee eaeM ae aT vafee Fa: an ar & atte 3a ac 8, athe Pat ate ae sort arfey anfai afer, wa: center ait at we iret Gra & far’ eat aren a eet as & Fare, Frenfia Fen ara & 1 eel ace Tories @, stone at fered ara, we oeitrer ar rere Fegan ser afew) eft tee wes itera PRET ‘wre entre eran @ SH Fee ore eae fod Sera set aeat Bi ste at dts Bare at a fer, Teihten a die @ fester Rear ara anf wether aa fesrga agin dared & sari suit at ot ‘after aren &, saree & fee, aig, , te, safe we kludge Weriftes gaye & wae Ge we sree ave @ are at wat 2 afer mere eye & get Be wr, Pre ‘afeorrrecresy ferezer eftar et wert @ ait frees Beat St wear tl uptifeen cht Praca: 1 an fs en ard & fe ee shied ee ee ‘Sart, go aifira went at Freafea aren Baht ve onaeye tar A at ects # fit gs fafa 27 executable Barer 2, ae afore ser area B waited At afer ed Freeh afoarn # uevitfies sf afore we cal i B a, ears 2 ae oe ene a PSE eT vader Gren &) ea eit gram & ea a oft sen TB, tee afar a we Pe gare & fae sare art Ft we: Rega opren at fara & seit aad suet a sg fore aftr aden sfc Rarer earsit ca sein Pa aren B | sete fiat ar sterr-srern are Bron 8 ae stair Ht age sett eter & ifs ae afte usitfies at ara azar ® sik ga awed ater ‘aor & fer, eee crema & ea Sasa are & etter A wee 8, fea fearee start @ iran & ‘fats cea at Seem a eae Bi ae HEAT a ET ‘erro sian sears aah fae A qian wer aera * weitere ar Frater: Flow Chart frat ft area 3 aera & free ar apret #1 @ Flow Chart starr % Peat wear & marae a1 fafa sara oh am & weft aan 8 eer ard we Perth fers are safe een aren 8 Flow Chart tam et ara fafa sete: at fee Operation Meaning Symbol a. Starvstop Represnis the begining and the end of the flow chart Tnputiourput | Represents the values to be given by the end user a and the result to be displayed =~ ir Represents the arthmatic operations to compute a value, Decision making/ | Reprents the logical checking to decide the flow of > Checking the sequence Looping Reprents looping which Is reprented based on <]|—> condition or value ofa variable [Connection Represents the continuing of flowchart in anotber oO place of page Flow lines [Represents the direction of low — © Plow Chart wet aa tive tt sieda arerre ET = at Fred eet ante, flow Chara zfs se we fr te 8 » Flow line 7 Rr + Flow Chart 4 sare ae 8 ht pra ant & ait tah ahatt ont & at gE eT art ste ert af, wae ear safe + Pediserasa & tow Char fread & Pra ie rite 4 Sect es st Flow line PAE aad hue ate wid 4 ae sare BA afk, aft GF A Flow line Famer sett “aft 2 Aa ar ft at art aet Flow line at at sre ig fz fin are ea gl a, frat att aeacana id aferba feat fren ft gargs et eye St sis ‘aft Flow Chart ar & va a8 sere ye we ft ‘ware att @ at Flow Chan a Faye tar area sda at cg arf cea ae a wart Flow Chart @ 342 3 & fore ee vanfeq actiafn ‘are — Algerittm aod Flowchart Declare variables numt, mum2 and sum Read numi and ‘sum sume a+b Display sum stop. Pseudo code feat tara at Feafert ae aft afer, fam at art ord st aera ad ad & atv ora bq ach Prato & sry art & itt ae ad Flaw Chart $741 Pseudo code i erat @ Frat atat % Pseudo code Flow Chart 3 t=: rafter fassee 8 Pseudo code & fafier carafe staan fare at orien itera fh afer 1 a @ fern stat 8 iif eee sera at fear et aecanpt cart @ sa: g@t storm flrare rer (Program Design Language) +1 a1 arat | Mathematical Operators: Meaning Example Operator + Addition A+B - Subtraction = A—B * Multiplication A+B ' Division AIB . Power A'S for A3 % Reminder A%B Relatioual Operators Meaning Example Operator < Less than A Greater than = A>B Greater tha or A>=B equal to Algerittm aod Flowchart ‘Operator Example Weaning AND A=BAND BB) Result is True ASB is false else trug ‘Selection control Statements ‘Selection Contral Example Meaning IF (Condition ) Then IF (X> 10) THEN condition X>10 is True a Yave5 execute the statement ENDIF ENDIF between THEN and ENDIF IF (Condition ) Then IF (X> 10) THEN If condition X>10 is True oe yeyes ‘execute the statement ELSE ELSE between THEN and ELSE oe YeYss, otherwise execute the 2-243 statements between ELSE ENDI ENDIF and ENDIF Loap control Statements ‘Selection Contral Example Meaning WHILE (Condition) WHILE (X= 10) Execute the loop as long as BO DO the condition is TRUE Ec print x i eK ENDDO ENDDO DO DO Execute the loop as long as print x the condition is false - xexH] UNTILL (Condition) UNTILL (X +10) GO TO statement also called unconditional transfer of control statement is used to transfer control of execution to another step/statement. . e.g. the statement GOTO a will transfer control to step/statement n, Note: We can use keyword INPUT or READ or GET to accept input(s) /value(s) and keywords PRINT or WRITE or DISPLAY to output the result(s). sare — fig eearail 1 art Frater 4 fore Pseudo code STEP 1: START STEP 2: READ a,b, ¢ STEP 3 - sum=a+b+e STEP 4: PRINT sum STEP 5 : STOP wetter ait weataré & ita ate Lae critter } wana & ah At een at farm sepefins so ar torr anf #1 re Feratia, wer getterd cevitftert a afera Fern 2. psitfeest ft qerar #f vet ard aftr: emt cher tarts 3. epithe ca tefl ar af ferat ver & fe age ag a | cath sie, ita fae ares ste stat at aati ae ararer ar 2 4. Upitten aid sare Fer ary adi fa ay 8 wal setrard ait utter Perel grr ary Pear rar 3. eesitheest gett ard at Geran # feel ste a a sored er errant aera BL 6. veranda aera strane erat & | staf wesitites at aware afore wetter sare Le weear a eet ea | fee ares eae safaeen, Foe farg sear acer 2. ae te aft aaea & aera at ate wie wees ae @ Rrenfira a 8 | 3. Miia an Bogen sit fate sect ardpsrerar a swefer ft site at ara & wie Sore Lovettend feed & aif at eae ect ar ee sree ater 2. ae enerean Sh fade ft afar were ara & | 3. ae we afta aearaa wars aT B 4. te fe ster at set 8 gear de® 5, are apreiann & Pecorer at Fae car 6.8 stoma Ss cereeara a sarerra ware & | aeitites & aT 1 ve: Fare fate, eerie rem tt ara 2, gad age area eran setter RT Lote after citfirer sort axa & fore St veil are are ‘sie 8 sera fees ohh fe eter By 2. vet ard # aang ved an ape aPeada es oe ett ad at fara aan ara, Example = Algorithm & Flowchart to Swap Two Numbers using Temporary Variable Algorithm Step-I Start Step-2 Input Two Nutibers Say NUMILNUM2 Step-3 Display Before Swap Values NUMI, NUM2 Algerittm aod Flowchart Step-§ NUMI = NUM2 Step-6 NUM2 = NUMI Step-7 Display Afier Swap Values NUMI,NUM Step-8 Stop flowchart NoMa s TEMe SOM NUN ‘smer Swap Algorithm & Flowchart to find the smallest of {wo numbers Algorithm, Step-I Start Step-2 Input two numbers say NUMI,NUM2 Step-3 IF NUMI < NUM2 THEN print smallest is NUMI ELSE print smallest is NUM2 ENDIF Step-4 Stop Flowehart Inout value ‘ot NOME Algorithm & Flowchart to find the largest of three numbers Alg Step-I Start Step-2 Read three nuinbers say nun! um2, umd Step-3 if num |>num2 then go to step-S Step-4 IF nu aum3 THEN Algerittm aod Flowchart print num2 is largest ELSE print num3 is largest ENDIF GOTO Step-6 Step-5 IF num |>aum3 THEN FLOWCHART Print Lange wih What will be the output of the following pseudocode? Integer i Seti while(i not equals 0) end while print numt is largest ELSE print num8 is | ENDIF Step-6 Stop Pri longest Muu [Note: A do while loop is 2 control flow statement th repeatedly executes the given Boolean condition at the end of the block] xecutes a block of cade at least ance, and then A)666 B)656 sss Dj6s4 Ans: D Explanation: Algerittm aod Flowchart In this program, one variable declared as i, and value initialized as 3. We are moving with do- while(Do while will execute the statement once and then it will check the condition) Step It will print i+3, here i value is 3. Sa i+3 is 6. On the ine, i will be decremented by 1, Then checking the conditions in da-whileQ) updated i value is 2 (2!=0),s0 condition loop continues. Step 2: It will print i#3, here updated i value is 2. So i+3 is 5. On the next line i will be decremented by 1. Then checking the conditions in da-while() updated i value is 1 (1!=O).s0 condition gets true. Here The loop continues Step 3: It will print i+3, here updated i value is 1. So it3is 4. On the next line i will be decremented by TiThen checking the condition in do while() i!-O» Here updated i value is © (0!=0),s0 condition gets false. Thus the loop gets terminated! E.g. code to explain this: Do white will execute the statement for the first time and then it-will check the condition. intis3; do| coutcci+3 } whileti!=0),

You might also like