Pseudocodes Others
Pseudocodes Others
3. A school is doing a check on the heights all its students of a class with15 students.
Write an algorithm, using pseudocode or a flowchart, which
inputs the height of all 15 students
Validate the height so that height between 3 to 7 feet is acceptable
outputs the average (mean) height
5.Write an algorithm, using pseudocode, to input three different numbers, multiply the two
larger numbers together and output the result. Use the variables: Number1, Number2 and
Number3 for your numbers and Answer for your result
7.Write pseudo code that performs the following: Ask a user to enter a number. If the number is between 1 and 5,
write the word blue. If the number is between 6 and 10, write the word red. if the number is between 11 and 15, write
the word green. If it is any other number, write that it is not a correct color option.
8.Write an algorithm using pseudocode to output all even numbers between 1 and 100
9.Write pseudo code to print all multiples of 5 between 1 and 100 (including both 1 and 100).
10. Write pseudo code that will count all the even numbers up to a user defined stopping point
11.A greenhouse is being monitored by a computer using 2 sensors, temperature sensor and oxygen sensor. If the
temperature exceeds 45°C or oxygen levels fall below 0.19, then an error message is output by the computer.
13.Write an algorithm, using pseudocode or otherwise, which inputs 450 numbers and outputs
• how many of the numbers were positive
• how many of the numbers were negative
How many zeros were entered?
15.Write a program to
Input speeds of 9 bikes
Print an error message if any exceeds speed limit (160)
Output how many bikes exceeded speed limit
How many bikes were on normal speed?
20.A school wants to monitor the number of hours spent by a class of 30 students on the
Internet.
Using pseudocode or otherwise, write an algorithm which will;
• for each student, input the times logged on and logged off
• calculate the length of time each student spends online
• output the average length of time per day spent by each student on the
Internet.
21.The weather conditions in Islamabad are being monitored over a year (365 days).
The values recorded per day are weather type and temperature (e.g.
CLOUDY, 25).
Write an algorithm, using pseudocode or flowchart only, which:
• inputs the weather type and temperature for each day
• outputs the number of days that were CLOUDY, RAINING, SUNNY or
FOGGY
• outputs the highest recorded temperature for the year
22.5000 numbers are being input which should have either 1 digit (e.g. 5), 2
digits (e.g. 36), 3
digits (e.g. 149) or 4 digits (e.g. 8567). Write an algorithm, using pseudocode
or flowchart only, which• inputs 5000 numbers• outputs how many numbers
had 1 digit, 2 digits, 3 digits and 4 digits
• outputs the % of numbers input which were outside the range
23.A country has four mobile phone network operators. Each mobile phone
number has eight digits. The first three digits identify the network operator:
333 ufone
300 Mobilink
312 Zong
345 Telenor
Write an algorithm, using pseudocode or flowchart only, which inputs 12
eight-digit mobile phone calls made during the day and outputs the number of
calls made on each of the four networks.
27.Ajmal has 2000 CDs, DVDs, videos and books in stock. Each item has a
unique 5-digit code with the first digit identifying the type of item, i.e.
1 = CD 2 = DVD 3 = video 4 = book
For example, for the code 15642 the 1 identifies a CD, and code 30055 the 3 identifies a video.
Write an algorithm, using pseudocode or flowchart, that
• Inputs the codes for all 2000 items
• Validates the input code (only accept 5-digit code which starts with 1,2,3 or 4)
• Calculates how many CDs, DVDs, videos and books are in stock
• Outputs the four totals
28.The exchange rate between the US Dollar (US$) and the Brazilian Real (R$)
changes every day.
Write an algorithm, using pseudocode or flowchart, which inputs the
exchange rate for every day over a 10 year period (assume that each year =
365 days) and then outputs the following:
• The average (mean) exchange rate
• The best (highest) and The worst (lowest) exchange rate
• The number of occasions when the exchange rate was above 2.0
30.A customer wants to compare prices of 1000 items sold in two supermarkets
(price1 and price2).
Write an algorithm, using pseudocode or a flowchart, which:
• inputs the two prices for all 1000 items
• outputs how many items were more expensive in supermarket 1
• outputs how many items were more expensive in supermarket 2
• outputs the largest and smallest price differences.
31.Write a pseudocode:
• input up to 20 numbers
• stop if the sum of the input numbers exceeds 50
• output the final sum
32.Using pseudo code or otherwise, write an algorithm which will take information about each
transaction at a supermarket till, calculate and output
• the number of sales,
• the number of refunds,
• the total amount of money in the till.
40.A school uses a computer to store student marks obtained in an end of term
mathematics exam. There are 150 students doing the exam and the
maximum mark is 100.
Write an algorithm, using pseudocode or otherwise, which
• inputs the marks for all students
• checks if each mark is in the correct range and, if not, the mark is re-input
• outputs the smallest mark
• outputs the highest mark
• outputs the average mark for the exam.
41.An estate agent advertises houses for sale. The customer enquiries for a 7-
day working week are entered weekly into a computer. Write an algorithm,
using pseudocode or a program flowchart only, which:
• inputs the number of customer enquiries each day,
• inputs the house price each customer enquires about,
• outputs how many customers enquired each day about houses costing less
than $100 000,
• outputs the percentage of all enquiries made during the week about houses
costing more than $500 000.
42.Input two values in two different variables A and B .if A is greater than B
then reverse their values.
44.Wages at Microsoft are paid using 20$ and 10$ bank notes. Write an algorithm
which will
Input the money
Only accept money which is multiple of 10
Output the number of 20$ notes required
Output the number of 10$ notes required
(you may use built-in functions e.g. int() ,MOD etc)
DECLARE sum, t2, t1, x : Integer
INPUT x
If x Mod 10 = 0 Then
t2 = Int(x / 20) //finding how many 20$ notes
re = x Mod 20 //save the remainder (which may be 10 or 0)
t1 = re / 10 //if remainder was 10 t1 will be 1 other wise 0
Print t2, t1
Else
Print "sorry number is not divisible by 10"
End If
46.Tickets are sold for a concert at 20$ each. If 10 tickets are bought, then the
discount is 10%, if 20 or more tickets are bought the discount is 20%.no more
than 25 tickets can be bought in a single transaction. Output the total cost of
tickets bought.
47.
Arrays
49.Input and store the names and marks for 30 students who have sat three computer science tests.
Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the
names in a one-dimensional array and the marks and total score for each student in one-dimensional
arrays. All the marks must be validated on entry and any invalid marks rejected
Calculate and store the total score for each student and calculate the average score for the whole
class. Output each student’s name followed by their total score, then output the average score for the
class.
Output the name and score of the students who was top scorer
50.input 30 numbers and output the position of maximum number. Also output how many numbers entered after the
maximum. Output the position of number with minimum value.
Miscellaneous
51.Write an algorithm which uses a While..Do..Endwhile loop and outputs the numbers 2,
4, 6 and 8.
54.Daniel lives in Italy and travels to Mexico, India and New Zealand. The times differences
are:
Country Hours Minutes
Mexico -7 0
India +4 +30
New Zealand +11 0
Thus, if it is 10:15 in Italy it will be 14:45 in India.
(a) Write an algorithm, using pseudocode or otherwise, which:
• Inputs the name of the country
• Inputs the time in Italy in hours (H) and minutes (M)
• Calculates the time in the country input using the data from the table
• Outputs the country and the time in hours and minutes
55- Input the time in minutes. Convert and print in hours and minutes.
56- First 100 units Rs. 8 per unit. Units above 100 till 300 is Rs. 12 per unit Units above 300 till 500
is Rs. 15 per unit all units above 500 is Rs. 20 per unit.
Write a program to Input the Units consumed and print the bill.
56- write a program for calculator which asks the user to input a number, then an arithmetic operator and then another
number, the program should give a correct answer according to given operation.
e.g 3 + 4 =7
57-number guessing game, give three tries, if user’s entered guess equals stored number or user attempted 3 tries, the
program will terminate.
58- input the total marks of 45 students and output the highest marks, also output how many students equals highest marks.