Practice Problems
Practice Problems
Before MID 1
Question 1 Any integer is input by the user. Write a pseudocode to find out whether
it is an odd number or even number.
Question 2 Find the absolute value of a number entered by the user.
Question 3 Write a pseudocode to calculate the total expenses. Quantity and price
per item are input by the user and discount of 10% is offered if the
expense is more than 5000.
Question 4 Write a pseudocode to determine whether the seller has made profit or
incurred loss. Also determine how much profit he made or loss he
incurred. Cost price and selling price of an item is input by the user.
Question 5 If the ages of Ahmed, Rayaan and Alyaan are input by the user, write a
pseudocode to determine the youngest of the three.
Question 6 Write a pseudocode to check whether a triangle is valid or not, when the
three angles of the triangle are entered by the user. A triangle is valid if
the sum of all the three angles is equal to 180 degrees.
Question 7 Any year is input by the user. Write a pseudocode to determine whether
the year is a leap year or not.
Question 8 In a company an employee is paid as under:
If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary
A–Z 65 – 90
a–z 97 – 122
0–9 48 – 57
Question #13:
A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5 and 6 spots. After
the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum
is 7 or 11 on the first roll, the player wins. If the sum is 2, 3 or 12 on the first roll (called
“craps”), the player loses (i.e., the “house” wins). If the sum is 4, 5, 6, 8, 9 or 10 on the first roll,
then that sum becomes the player’s “point.” To win, you must continue rolling the dice until you
“make your point.” The player loses by rolling a 7 before making the point.
Question #14:
Write pseudocode segments that accomplish each of the following:
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the pseudocode pieces developed in (a) and (b) to write a pseudocode that inputs an
integer between 1 and 32767 and prints it as a series of digits, each pair of which is separated
by two spaces.
Question #15:
Write a pseudocode that takes an integer value and returns the number with
its digits reversed. For example, given the number 7631, the function should return 1367.