0% found this document useful (0 votes)
2 views5 pages

Exercises

The document contains a series of exercises in pseudocode that cover various programming concepts including sequences, conditional statements, and loops. Each exercise requires writing pseudocode to perform specific calculations or logic operations, such as calculating areas, converting units, and determining conditions like leap years. The exercises are designed to reinforce understanding of programming fundamentals and problem-solving skills.

Uploaded by

tharrnaymin1438
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)
2 views5 pages

Exercises

The document contains a series of exercises in pseudocode that cover various programming concepts including sequences, conditional statements, and loops. Each exercise requires writing pseudocode to perform specific calculations or logic operations, such as calculating areas, converting units, and determining conditions like leap years. The exercises are designed to reinforce understanding of programming fundamentals and problem-solving skills.

Uploaded by

tharrnaymin1438
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/ 5

== Sequence Exercises ==

1. Write a Pseudocode program to print the area and perimeter of a rectangle.


2. Write a Pseudocode program to print the area and perimeter of a circle.
3. Write a Pseudocode program to find the third angle of a triangle.
4. Write a Pseudocode program to find the area of any triangle using Heron's formula. (the area of the
Scalene Triangle) (hint: S=(a+b+c)/2)
5. Write a Pseudocode program that calculates the volume of a sphere.
(Sample Output:V=4/3 pi r^3)
6. Write a Pseudocode program that calculates the volume of a cylinder.
7. Write a Pseudocode program that reads a number and displays the square, cube, and fourth power.
8. Write a Pseudocode program to print the sum (addition), multiply, subtract, divide and remainder of
two numbers
9. Write a Pseudocode program that takes three numbers as input to calculate and print the average of
the numbers.
10. Write a Pseudocode program to input the weight of the body in pound and change to kg scale. (1
pound= 0.454 kg)
11. Input the temperature in Fahrenheit and change to Celsius. (F − 32) × 5/9 = 0°C
12. Find the BMI of the person. Input weight and height.
(hint: BMI=weight/height2)
13. Write a Pseudocode program that reads a number in inches and converts it to meters.
(Note: One inch is 0.0254 meter.)
14. Write a program in Pseudocode that converts kilometers per hour to miles per hour.
(hint: 1 mile = 1609 meters).
15. Write a Pseudocode program to round up integer division results.
16. Write a Pseudocode program to swap two variables.
17. Write a Pseudocode program to input time in seconds and output the time in hours:minutes:seconds
format.
18. Write a Pseudocode program that reads an integer between 0 and 1000 and adds all the digits in the
integer.
Input an integer between 0 and 1000:565
(The sum of all digits in 565 is 16)
19. Write a Pseudocode program to take the user for a distance (in meters) and the time taken (as three
numbers: hours, minutes, seconds), and display the speed, in meters per second, kilometers per
hour and miles per hour (hint: 1 mile = 1609 meters).

== IF and CASE 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

• Write a program to determine the cost of an automobile insurance premium, based on


driver's age and the number of accidents that the driver has had.
• The basic insurance charge is $500. There is a surcharge of $100 if the driver is under 25
and an additional surcharge for accidents:
# of accidents Accident Surcharge
1 50
2 125
3 225
4 375
5 575
6 or more No insurance
23. Write a program that recommends the number of calories a person should eat each day.
Calories are units of energy found in all foods. Base your recommendation on the person's
weight and whether the person has an active or sedentary(inactive) lifestyle. If the person is
sedentary, that person's activity factor is 13. If the person is active, that person's activity factor
is 15. Multiply the activity factor by the person's weight to get the recommended number of
calories. Start your program by:
 having the user enter their weight, as a REAL number;
 having the user enter whether they have active or sedentary lifestyle, as a character, 'A'
for active or 'S' sedentary;
 use a CASE (or ELSE IF) selection statement to use the appropriate calculation for the
recommended calories for the selected lifestyle;
 print out your results on the screen.
24. Write a program which reads a year (integer) from the user and decides whether that year is a
leap year. A year is a leap year (and so contains a February 29) if it is divisible by 4. But if the
year is also divisible by 100 then it is not a leap year, unless it is divisible by 400. This
means that years such as 1992, 1996 are leap years because they are divisible by 4 and are not
affected by the rest of the rule which applies to century years such as 1900 and 2000. Century
years are not leap years except where they are a multiple of 400. Hence, the years 1700, 1800
and 1900 were not leap years and did not contain a February 29. But the year 2000 was a leap
year, the first such century leap year since 1600.

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 ===

25. Print First 10 natural numbers using while loop


26. Accept number from user and calculate the sum of all number from 1 to a given
number
27. Print multiplication table of a given number.
28. Display numbers from -10 to -1 using for loop
29. Write a pseudo code to read in 10 numbers and compute the average, maximum and
minimum values.
30. Two numbers are entered through the keyboard. Write a program to find the value of
one number raised to the power of another using for loop.
31. Write pseudocode to count how many digits include in a number set (e.g. 856497)
32. Write a program that reads a set of integers (e.g.856497), and then prints the sum of
the even and odd integers.
33. Write a program that reads a set of integers (e.g.856497), and then output the count of
the even and count of odd integers.
34. Write a program that prompts the user to input an integer and then outputs the
number with the digits reversed. For example, if the input is 12345, the output should
be 54321.
35. Display Fibonacci series up to 10 terms. (output e.g.1, 1, 2, 3, 5, 8, 13, 21, ….….)
36. Write a program to read in numbers until the number -999 is encountered. The sum of
all number read until this point should be printed out.
37. Accept number from user and calculate the sum of all number from 1 to a given
number
38. Write a program to calculate the sum of following series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
39. Write a program that generates a random number BETWEEN 1 TO 100 and asks the
user to guess what the number is. If the user's guess is higher than the random number,
the program should display "Too high, try again." If the user's guess is lower than the
random number, the program should display "Too low, try again." The program should
use a loop that repeats until the user correctly guesses the random number.
40. Print the following pattern

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.

You might also like