Exercises
Exercises
1. Write a Pseudocode program to get a number from the user and print whether it is positive or
negative or zero.
2. Check the input number is odd or even.
3. Write a Pseudocode program that requires the user to enter a single character from the
alphabet. Print Vowel or Consonant, depending on user input.
4. Write a Pseudocode program that takes a year from the user and prints whether it is a leap year
or not.
5. Find maximum number from the two input integer numbers.
6. Find minimum number from the two input integer numbers.
7. Write a Pseudocode program that takes three numbers from the user and prints the greatest
number.
8. Check the age is which era. If the age is greater or equal 10 print Teenager. If the age is greater
or equal 18 print Adult. If the age is greater than or equal 60 print Old, otherwise print Child.
9. Check the mark and print the grade. If the mark is greater than 50 then grade is D, if the mark is
greater than 60 then grade is C. If the mark is greater than 70 then grade is B, If the mark is
greater than 80 then grade is A. If the mark is greater than 90 then grade is A* else grade is E.
10. Write a pseudo code to input day number and print day name.
11. Write a pseudo code to input month number and print number of days in that month.
12. Write a pseudo code to input marks of three subjects Physics, Chemistry, Biology. Calculate
percentage and grade according to following:
Percentage >= 90% : Grade A*
Percentage >= 80% : Grade A
Percentage >= 70% : Grade B
Percentage >= 60% : Grade C
Percentage >= 5 0% : Grade D
Percentage >= 40% : Grade E
13. Write a pseudo code to check whether a number is divisible by 5 and 11 or not.
14. Ask the user for a number. If it is less than 12, add 10. Print the number.
15. Ask the user for a number. Give an error if the number is negative.
16. Ask the user for the day portion of the date. If it is greater than 31 or less than 1, give them an
error message.
17. Ask the user for a number. If it is less than 12, add 5, otherwise add 8. Print the number.
18. Ask the user for a number. If it is less than 12, print the number. Otherwise, print nothing.
19. Ask the user for a number. If it is less than 12, add 5. If it is greater than 20, add 50. Print the
number.
20. Ask the user for a quantity. If they are buying over 100, the price will be 30. If it they are buying
over 50, the price is 50. Otherwise, the price is 70. Print the price and total cost.
21. Ask the user for a quantity. The base price is 70. Give a 10% discount if they buy more than 50.
Give a 20% discount if they buy more than 100. Print the price and total cost.
22. An Auto Insurance Program
Challenge 1: If you finish the exercises early, try to solve this problem. Write a program that
reads a date from the user in numeric form. For example, February 17, 2003 would be entered
as the three integers 2, 17, and 2003. Your program must then determine if the date is a “valid”
date. Use the following information to determine if the date is valid: January, March, May, July,
August, October, and December all have 31 days. April, June, September, and November all have
30 days. February has 28 days in a non-leap year and 29 days in a leap year. Echo the input and
print either “valid date” or “invalid date” as output.
=== Loop Exercises ===
41. Write a program to make such a pattern like right angle triangle with a number which
will repeat a number in a row.
42. Write a program to make such a pattern like right angle triangle with number increased
by 1.