0% found this document useful (0 votes)
15 views7 pages

Basic Input

The document provides pseudocode examples for basic input/output operations, mathematical calculations, loops, conditions, and real-life problem-solving scenarios. It includes instructions for tasks such as adding numbers, checking if a number is even or odd, calculating areas, and simulating an ATM withdrawal. Each pseudocode is structured with clear BEGIN and END statements, making it easy to follow.

Uploaded by

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

Basic Input

The document provides pseudocode examples for basic input/output operations, mathematical calculations, loops, conditions, and real-life problem-solving scenarios. It includes instructions for tasks such as adding numbers, checking if a number is even or odd, calculating areas, and simulating an ATM withdrawal. Each pseudocode is structured with clear BEGIN and END statements, making it easy to follow.

Uploaded by

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

Basic Input/Output and Math Operations

1. Write a pseudocode to add two numbers and display the result.

BEGIN

INPUT number1

INPUT number2

sum = number1 + number2

PRINT sum

END

2. Write a pseudocode that takes a number and prints whether it is even or odd.

Check if a number is even or odd:

BEGIN

INPUT number

IF number MOD 2 = 0 THEN

PRINT "Even"

ELSE

PRINT "Odd"

END IF

END

3. Write a pseudocode to calculate the area of a rectangle.

Calculate the area of a rectangle:

BEGIN

INPUT length

INPUT width

area = length * width

PRINT area

END

4. Write a pseudocode that asks for a number and prints its square.

Print the square of a number:

BEGIN
INPUT number

square = number * number

PRINT square

END

5. Write a pseudocode that converts temperature from Celsius to Fahrenheit.

Convert temperature from Celsius to Fahrenheit:

BEGIN

INPUT celsius

fahrenheit = (celsius * 9/5) + 32

PRINT fahrenheit

END

Loops and Repetition

6. Write a pseudocode that prints numbers from 1 to 10.

Print numbers from 1 to 10:

BEGIN

FOR i = 1 TO 10

PRINT i

END FOR

END

7. Write a pseudocode that calculates the sum of numbers from 1 to N, where N is user input.

BEGIN

INPUT N

sum = 0

FOR i = 1 TO N

sum = sum + i

END FOR

PRINT sum

END
8. Write a pseudocode that prints the multiplication table of a number entered by the user.

BEGIN

INPUT number

FOR i = 1 TO 10

result = number * i

PRINT result

END FOR

END

9. Write a pseudocode that counts down from 10 to 1.

BEGIN

FOR i = 10 DOWNTO 1

PRINT i

END FOR

END

10. Write a pseudocode that asks for 5 numbers and calculates their average.

BEGIN

sum = 0

FOR i = 1 TO 5

INPUT number

sum = sum + number

END FOR

average = sum / 5

PRINT average

END

Conditions and Branching

11. Write a pseudocode to check whether a number is positive, negative, or zero.

BEGIN

INPUT number
IF number > 0 THEN

PRINT "Positive"

ELSE IF number < 0 THEN

PRINT "Negative"

ELSE

PRINT "Zero"

END IF

END

12. Write a pseudocode to find the largest of three numbers.

BEGIN

INPUT num1

INPUT num2

INPUT num3

IF num1 > num2 AND num1 > num3 THEN

PRINT num1

ELSE IF num2 > num1 AND num2 > num3 THEN

PRINT num2

ELSE

PRINT num3

END IF

END

13. Write a pseudocode to decide if a person is eligible to vote (age 18+).

BEGIN

INPUT age

IF age >= 18 THEN

PRINT "Eligible to Vote"

ELSE

PRINT "Not Eligible to Vote"

END IF
END

14. Write a pseudocode to display the grade based on a student's score. (e.g., A for 90+, B for 80–
89...)

BEGIN

INPUT score

IF score >= 90 THEN

PRINT "Grade A"

ELSE IF score >= 80 THEN

PRINT "Grade B"

ELSE IF score >= 70 THEN

PRINT "Grade C"

ELSE IF score >= 60 THEN

PRINT "Grade D"

ELSE

PRINT "Grade F"

END IF

END

15. Write a pseudocode that checks whether a given year is a leap year.

BEGIN

INPUT year

IF (year MOD 4 = 0 AND year MOD 100 != 0) OR (year MOD 400 = 0) THEN

PRINT "Leap Year"

ELSE

PRINT "Not a Leap Year"

END IF

END
Problem-Solving / Real-Life Scenarios

16. Write a pseudocode for a simple ATM withdrawal that checks balance before withdrawing.

BEGIN

INPUT balance

INPUT withdrawal_amount

IF withdrawal_amount <= balance THEN

balance = balance - withdrawal_amount

PRINT "Withdrawal Successful"

PRINT "Remaining Balance: " + balance

ELSE

PRINT "Insufficient Funds"

END IF

END

17. Write a pseudocode that simulates a login system with a preset username and password.

BEGIN

INPUT username

INPUT password

IF username = "user123" AND password = "pass123" THEN

PRINT "Login Successful"

ELSE

PRINT "Invalid Username or Password"

END IF

END

18. Write a pseudocode for a shopping cart that calculates total price with tax.

BEGIN

INPUT item_price

INPUT tax_rate

total_price = item_price + (item_price * tax_rate / 100)

PRINT "Total Price: " + total_price


END

19. Write a pseudocode to simulate a basic calculator (Add, Subtract, Multiply, Divide).

BEGIN

INPUT num1

INPUT num2

PRINT "Select operation: 1. Add 2. Subtract 3. Multiply 4. Divide"

INPUT operation

IF operation = 1 THEN

result = num1 + num2

ELSE IF operation = 2 THEN

result = num1 - num2

ELSE IF operation = 3 THEN

result = num1 * num2

ELSE IF operation = 4 THEN

result = num1 / num2

END IF

PRINT "Result: " + result

END

20. Write a pseudocode that simulates a traffic light system (Red, Yellow, Green cycle).

BEGIN

WHILE TRUE

PRINT "Red Light"

WAIT 30 SECONDS

PRINT "Yellow Light"

WAIT 5 SECONDS

PRINT "Green Light"

WAIT 30 SECONDS

END WHILE

END

You might also like