0% found this document useful (0 votes)
15 views

Pseudocodes Others

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 views

Pseudocodes Others

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/ 6

1.

Write an algorithm, using pseudocode or a flowchart, which:


_ inputs 7 marks
_ add these marks together
_ outputs the final total

2. Write an algorithm, using pseudocode or a flowchart, which:


_ inputs 5 numbers
outputs their average

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

4. Input three numbers and output the lowest number

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

6.input 3 numbers and output the sum of two smaller numbers

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.

12.The Fuel Economy for 10 cars is to be calculated using the formula


( fuel economy=distance/fuel used).
Write an algorithm, using pseudocode or flowchart, which inputs the Distance
Travelled (km) and the Fuel Used (litres) for 10 cars.
• Fuel Economy for each car
• average (mean) Fuel Economy for all of the cars input
• the best Fuel Economy (i.e. highest value)
• the worst Fuel Economy (i.e. lowest value)

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?

14.Write an algorithm, using pseudocode or otherwise, which inputs 8


temperatures and outputs
• how many of the temperatures were below 50°C
• how many of the temperatures were above -25°C
How many temperatures were invalid (which are outside the above range)
• the lowest temperature.

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?

16.Write an algorithm, using pseudocode or flowchart which;


• inputs 10 numbers
• checks whether each number is in the range -10 to + 10
• outputs how many of the input numbers were out of range
• outputs the percentage of input numbers which were out of range.
17.Write an algorithm, using pseudocode or flowchart only, which:
• Inputs 1000 numbers
• outputs how many of these numbers were whole numbers (integers) and
even numbers
(You may use INT(X) in your answer e.g. Y = INT (14.56) gives the value Y = 14)

18.Write an algorithm, using pseudocode or flowchart only, which:


• inputs 1000 numbers
• outputs how many of these numbers were even and odd (odd numbers are
not divided by 2)

19.Write an algorithm using either pseudocode or a flowchart, to:


• input a positive integer
• use this value to set up how many other numbers are to be input
• input these numbers
• calculate and output the total and the average of these numbers.

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.

24.A school has 1500 students. It is conducting a survey on their music


preferences. Each student uses a computer and inputs their name and then
chooses one of 5 options:
• rock (input value 1)• soul (input value 2)• pop (input value 3) • jazz (input value 4)
• classical (input value 5)
Write an algorithm, using pseudocode or a flowchart, which:
• inputs the choice of all 1500 students (values 1 to 5)
• outputs all the names of the students who chose classical music
• outputs the percentage who chose each option.

25.A school has 1800 students.


(a) Write an algorithm, using pseudocode or otherwise, which
• inputs Student ID for all 1800 students
• inputs the start date and leaving date for each student
• carries out a check to ensure the second date is later
• if error, increments error counter
• outputs the percentage of errors

26.Using pseudocode or otherwise, write an algorithm that will input store 25


marks and output the number of DISTINCTION, MERIT, PASS or FAIL
grades.
A mark greater than 95 will get a DISTINCTION, a mark between 80 to 95
(inclusive) will get a MERIT and a mark between 79 and 50 (inclusive) will get
a PASS…

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

29.Write an algorithm, using pseudocode or a program flowchart only, which:


• inputs the population and land area for 500 countries,
• calculates the population density (i.e. population/land area) for every
country,
• outputs the largest and smallest population density,
• outputs the average population for all 500 countries.

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.

33.(a) Write an algorithm, using pseudocode or a flowchart, which


_ inputs a set of positive numbers (which end with -1)
_ outputs the average (mean) value of the input numbers
_ outputs the value of the largest (highest) number input

34.Write an algorithm, using pseudocode or a flowchart, which


_ inputs a whole number (which is > 0)
_ calculates the number of digits in the number
_ outputs the number of digits and the original number
(E.g. 147 would give an output of 3, 147)

35.Write an algorithm, using pseudocode or flowchart only, which


• inputs both sensor readings
• Checks the sensor input values and outputs a warning message if either are
out of range
•output how many readings were out of range. The process ends when reading is negative.

36.Write an algorithm, using pseudocode or a flowchart, which


_ inputs a whole number (which is > 0)
_ calculates the number of digits in the number
_ outputs the number of digits and the original number
(E.g. 213.25 would give an output of 3, 213.25)
int(213.25) will return 213

37.A survey is being carried out which involves reading and


recording sound
levels near a busy road junction. Once all the data are
collected, they are
input manually into a computer. A sound level of 0 decibels
(0 dB) is input to
indicate the end of the data.
Write an algorithm, using pseudocode or a flowchart, which:
Inputs all the sound levels
After a sound level of 0 is input, outputs the following:
Average sound level
Highest recorded sound level.

39.A school has 1000 students sitting final examinations.


Each student sits eight examinations.
Write an algorithm, using pseudocode or a flowchart, which:
• inputs the marks for all 8 examinations for each student
• outputs for each student the average mark for their 8
examinations
• outputs the highest mark overall

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.

43.Diagram show a rail network


The rail network consists of 10
stations. The fare between
each station is $2. there is a 10% discount when 3 or more passengers travel together.
Using pseudocode, flowchart or otherwise, write an algorithm to:
Input the starting station number, the destination station number and the
number of passengers
Calculate the total fare and output the amount to be paid
Calculate the change (if any)
Issue the rail tickets and change

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

45.Write an algorithm using pseudocode, flowchart or a programming language


Input and store two numbers using two variables e.g. n1 and n2
Output numbers in reverse order so that n1 stores the value of n2 and n2
stores the value of n1

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

48.Write an algorithm, using pseudocode or a flowchart, which


Inputs and store 50 temperatures
Output the average temperature
Output how many temperatures were above and below average temperature

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.

52.Customers can withdraw cash from an Automatic Teller Machine (ATM).


• withdrawal is refused if amount entered > current balance
• withdrawal is refused if amount entered > daily limit
• if current balance < $100, then a charge of 2% is made
• if current balance $100, no charge is made
Write an algorithm which inputs a request for a sum of money, decides if a withdrawal can
be made and calculates any charges. Appropriate output messages should be included

53.The manufacturing cost of producing an item depends on its complexity. A company


manufactures three different types of item, with costs based on the following calculations:
Item type 1: item cost = parts cost * 1.5
Item type 2: item cost = parts cost * 2.5
Item type 3: item cost = parts cost * 5.0
The company makes 1000 items per day.
Write an algorithm, using pseudocode, flowchart or otherwise, which
• inputs the item type and parts cost of each item
• outputs the item cost for each item
• calculates and outputs the average (mean) item cost per day (based on 1000 items
being made).

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.

You might also like