PseudoCode & Flowchart Examples

Transcription

PSEUDOCODE & FLOWCHARTEXAMPLESC10 EXAMPLESwww.csharp-console-examples.com

Pseudocode Pseudocode is a compact and informal high-leveldescription of a program using the conventions of aprogramming language, but intended more forhumans. There is no pseudocode standard syntax and so attimes it becomes slightly confusing when writingPseudocode and so let us understand pseudo codewith an example.

Pseudecode Syntax FOR THOSE TUTORIALS I'LL USE THAT SYNTAX INPUT – indicates a user will be inputting something OUTPUT – indicates that an output will appear on the screen WHILE – a loop (iteration that has a condition at the beginning) FOR – a counting loop (iteration) REPEAT – UNTIL – a loop (iteration) that has a condition at the end IF – THEN – ELSE – a decision (selection) in which a choice is made any instructions that occur inside a selection or iteration are usually indented

Pseudocode & Flowchart Example 1Add Two Numbers123456789BEGINNUMBER s1, s2, sumOUTPUT("Input number1:")INPUT s1OUTPUT("Input number2:")INPUT s2sum s1 s2OUTPUT sumEND

Pseudocode & Flowchart Example 2Calculate Perimeter of Rectangle123456789BEGINNUMBER b1,b2,area,perimeterINPUT b1UNPUT b2area b1*b2perimeter 2*(b1 b2)OUTPUT alanOUTPUT perimeterEND

Pseudocode & Flowchart Example 3Find Perimeter Of Circle using Radius23456BEGINNUMBER r, perimeterINPUT rarea 3.14*2*rOUTPUT perimeterEND

Pseudocode & Flowchart Example 4Calculate sales taxes3456789101112131415BEGINNUMBER price, tax, taxRate, totalOUTPUT "Enter Product Price"INPUT priceOUTPUT "Enter tax rate amoung 1 and 100"OKU taxRatetax price* taxRate/100total price taxOUTPUT "Product tax " taxOUTPUT "Product total price " totalEND

Pseudocode & Flowchart Example 5Check a Number is Positive or NegativeBEGIN5678910111213141516NUMBER numOUTPUT "Enter a Number"OKU numIF num 0 THENOUTPUT "Entered number is positive"ELSE IF num 0 THENOUTPUT "Entered number is negative"ELSEOUTPUT "Entered number is zero"ENDIFEND

Pseudocode & Flowchart Example 6Find the biggest of three (3) Numbers234567891011121314151617BEGINNUMBER num1,num2,num3INPUT num1INPUT num2INPUT num3IF num1 num2 AND num1 num3 THENOUTPUT num1 "is higher"ELSE IF num2 num3 THENOUTPUT num2 "is higher"ELSEOUTPUT num3 "is higher"ENDIFEND

Pseudocode & Flowchart Example 7Print Numbers from 1 to 100BEGIN2 NUMBER counter34 FOR counter 1 TO 100 STEP 1 DO5OUTPUUT counter6 ENDFOR78 END

Pseudocode & Flowchart Example 8Read 50 numbers and find their sumBEGINNUMBER counter, sum 0, numFOR counter 1 TO 50 STEP counter DOOUTPUT "Enter a Number"INPUT numsum sum numENDFOROUTPUT sumEND

Pseudocode & Flowchart Example 9Read 10 numbers and find sum of even numbers123456789101112131415BEGINNUMBER counter, sum 0, numFOR counter 1 TO 10 STEP 1 DOOUTPUT "Enter a Number"INPUT numIF num % 2 0 THENsum sum numENDIFENDFOROUTPUT sumBİTİR

Pseudocode & Flowchart Example 10Calculate the Square Root of a NumberBEGINNUMBER root 1, counter 0,numOUTPUT "Enter a number for calculate the root"INPUT numWHILE sayac sayi 1 THENi i 1root (num/root root)/2END WHILEOUTPUT rootEND

csharp-console-examples.comFor more pseudocode ve flowchartexamplesclick here

Pseudocode Pseudocode is a compact and informal high-level description of a program using the conventions of a