You are on page 1of 2

Course Title Instructor Submission Date Weightage Computer Programming (for Engineers) Maryam Kausar 15th Oct for S9 and 16th Oct for S8 4% Absolute

Write algorithms and convert them into their equivalent pseudocodes of the following problems. 1. Write an algorithm that reads in the radius of a circle as an integer and prints the circle's diameter, circumference and area. Use the constant value 3.14159 for pi. 2. Assuming there are 7.481 gallons in a cubic foot, write an algorithm (and make its flowchart) that asks the user to enter a number of gallons, and then displays the equivalent in cubic feet.

3.

In the heyday of the British Empire, Great Britain used a monetary system based on pounds, shillings, and pence. There were 20 shillings to a pound, and 12 pence to a shilling. The notation for this old system used the pound sign, , and two decimal points, so that, for example, 5.2.8 meant 5 pounds, 2 shillings, and 8 pence. (Pence is the plural of penny.) The new monetary system, introduced in the 1950s, consists of only pounds and pence, with 100 pence to a pound. Well call this new system as decimal pounds. Thus 5.2.8 in the old notation is 5.13 in decimal pounds (actually 5.1333333). Write an algorithm (and make its flowchart) to convert the old poundsshillings-pence format to decimal pounds. An example of the users interaction with the program would be Enter pounds: 7 Enter shillings: 17 Enter pence: 9 Decimal pounds = 7.89

4. Write an algorithm that asks the user to enter two integers, obtains the numbers from the user, and then prints the larger number followed by the words "is larger." If the numbers are equal, print the message "These numbers are equal."

5. A worker is paid at the hourly rate of \$8 per hour for the first 35 hours worked. Hereafter overtime is paid at 1.5 times the hourly rate for the next 25 hours worked and 2 times the hourly rate for further hours worked. Write an algorithm to input the number of hours worked per week, calculate and output the overtime paid.

6. The process of finding the largest number (i.e., the maximum of a group of numbers) is used frequently in computer applications. For example, a program that determines the winner of a sales contest inputs the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write an algorithm (and make its flowchart) that uses a while statement to determine and print the largest number of 10 numbers input by the user. Your algorithm should use three variables, as follows: [4] counter: A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed). number: largest: The current number input to the program. The largest number found so far.

7. Write an algorithm (and make its flowchart) that prints the powers of the integer 2, namely 2, 4, 8, 16, 32, 64, etc. Your while loop should not terminate (i.e., you should create an infinite loop).