0% found this document useful (0 votes)
26 views2 pages

Pseudo Code

Uploaded by

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

Pseudo Code

Uploaded by

ekemaankhan2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

DECLARE array[10]
DECLARE evenCount, oddCount: INTEGER
evenCount = 0
oddCount = 0

FOR i = 0 TO 9 THEN
OUTPUT "Enter number ", i+1, ": "
INPUT array[i]
ENDFOR
FOR i = 0 TO 9 THEN
IF array[i] MOD 2 = 0 THEN
evenCount = evenCount + 1
ELSE
oddCount = oddCount + 1
ENDIF
ENDFOR

// Output the counts


OUPUT "Even numbers: ", evenCount
OUPUT "Odd numbers: ", oddCount

2. DECLARE total, cost: REAL


DECLARE choice: CHAR
total = 0
choice = 'Y'

WHILE choice = 'Y' OR choice = 'y' DO


OUTPUT "Enter the cost of the item: "
INPUT cost
total = total + cost

OUTPUT "Do you want to continue? Press Y/N: "


INPUT choice
ENDWHILE

OUTPUT "The total grocery bill is: ", total

3. DECLARE num1, num2, result: REPEAT


DECLARE operator, choice: CHAR
REPEAT
OUPTUT "Enter the first number: "
INPUT num1
OUTPUT "Enter the second number: "
INPUT num2
OUPUT "Enter operator (+, -, *, /): "
INPUT operator
CASE operator OF
'+':result = num1 + num2
'-':result = num1 - num2
'*':result = num1 * num2
'/':result = num1 / num2
OUTPUT "Result: ", result
OTHERWISE OUTPUT "Invalid operator. Please enter +, -, *, or /."
ENDCASE
OUTPUT "Do you want more calculations? Press Y/N: "
INPUT choice
UNTIL choice = 'N' OR choice = 'n'
OUPUT "Calculator program has ended."

You might also like