Вы находитесь на странице: 1из 7

1

Problems for Algorithm Development: SEQUENCE: 1. Input the outside and the inside diameter (IN_DIA, OUT_DIA) of a pipe. Calculate and print the thickness (T) of the wall of the pipe. 2. Read a temperature in degrees Fahrenheit, output in degrees Centigrade. F= (9/5) * C + 32. 3. Read an angle expressed in degrees, minutes and seconds, output in radians. 4. Read current (I_AMP) flowing through a cable and the resistance (R_OHM) of the cable, compute and output the power loss (P_WATT) through the cable. P = RI2 5. A box contains Philippine coins. How much money is in the box? Assume: n1 P5.00 coin. n2 P1.00 coin n3 25 centavo coin n4 10 centavo coin n5 5 centavo coin. 6. An electrical wire supplier sells wire in 500-foot rolls, 300 foot rolls, and 100 foot rolls and the number of feet additional wire to be given to the customer. Sample output: Enter length of wire needed by a customer: 950 950 feet requires: 500 foot roll(s) 300 foot roll(s) 100 foot roll(s) Addl feet wire

1 1 1 50

7. Input the amount of purchase which is less than P100.00. Calculate the change of P100.00 given by the customer with the following breakdown: P 50.00 - _______________; P 20.00 - _______________; P 10.00 - _______________; P 5.00 - _______________; P 1.00 - _______________; Note: Purchases are all in pesos. No centavos. 8. If a, b and c represent the three sides of a triangle, then the area of the triangle is:
= s ( s a )( s b )( s c )

where : s= (a+b+c)/2

Also the radius of the largest inscribed circle is given by: R_INSC = A/s and the radius of the smallest circumscribed circle is: R_CIRC = abc/(4A) Calculate the area of the triangle, the area of the largest inscribed circle, and the area of the smallest circumscribed circle given a value for a, b and c. 9. Suppose that P pesos are invested at an annual rate of I (expressed in decimal). If the interest is reinvested, then after N years the total amount of money, A, can be determined as: A = P(1+R)N (Known as the law of compound interest) 10. The volume of a pyramid is taken from the formula: V = 1/3 x AREA OF BASE x ALTITUDE Given the dimensions of a pyramid, calculate the cost of materials for making that pyramid from a solid cinder block with a 16 x 8 x 8 dimensions. Test your algorithm when the pyramid is 40 x 30 meters and cinderblocks cost P21.77 per block. CONDITIONAL 11. 12. Read three resistors and the connection desired, compute the total resistance based on desired connection. Input three numbers (X,Y,Z). Determine and output the following: a) highest number (HN) b) smallest number (SN) c) the numbers in ascending order d) the numbers in descending order e) only the odd numbers f) the average of the 3 numbers. A leap year is a year divisible by 4 unless it is a century year, in which case it must be divisible by 400 to be a leap year. Read a year and output a message whether the year is a leap year or otherwise. There are 15 numbers. Output the first, middle and last numbers. A professor converts following way: 93 100 87 92 80 86 70 79 below 70 Read a numeric grade and numeric grades to letter grades in the

13.

14. 15.

A B C D F output the equivalent letter grade.

16. 17. 18.

Write a program that reads an integer, then determine if it is a prime number or not. Write a message saying so. Given two numbers, write a program that would determine the greatest common denominator of the two. Parking charge per hour at Baguio Center Mall underground parking is as follows: P 5.00 - minimum charge for 2 hours parking or less, P 1.50/hr.- additional charge in excess of 2 hours parking, P 25.00 - maximum charge. Input : number of hours (HRS) the vehicle was parked. Output : parking charge (CHARGE). Note: a fraction of an hour is charged 1 hour. Example: 5 hours and 15 minutes should be entered as 6 hours.

19.

A telephone area code is a three digit number. The first of which is either 1 or 9, the second is any number among 5, 6, 7, 8, and 9. The third digit is any non zero number. Read a three digit number and checks to see if it is a valid code. Output a message saying so. Read the ID number and course of some Engineering students. Data input is terminated by an ID number of 999. Tally and output as required: Department: Number of Students: EE xx CE xx IE xx ME xx ChE xx ECE xx The ABC Electric Company bases its electricity charges on two rates. Customers are charged P 30.117 per kilowatt-hour (KWH) for the first 400 KWH used in a month, and P0.23 for all KWH used thereafter. Read in the consumption and output amount to be charged to the customer. A certain store has the following scheme: Commodity Code: A commodities are discounted by 15% B commodities are taxed by 10% C commodities are charged as priced Read the commodity code, quantity of the commodities bought and the unit price and output the amount to be paid by the customer. A 5 horsepower motor has an following: P 3.00 /kilowatt-hr for P 2.98 /kilowatt-hr for P 2.96 /kilowatt-hr for efficiency of 74.6%. Power rates are the the 1st 50 kilowatt-hrs. the 2nd 50 kilowatt-hrs. the 3rd 50 kilowatt-hrs.

20.

21.

22.

23.

And so on until a minimum cost of P 1.50 per kilowatt-hour is reached. Calculate and print the cost to run the motor continuously for 287 days. LOOPS: 24. 25. 26. There are 5 numbers, determine the factorial of each number. Read a number and calculate and output its factorial. Input and print a number (NUM), its reverse by using operators div and mod. If the last digit is zero, replace it with a one(1) before reversing the number. Output also the sum of all the digits. Example 1: Input: 543267 Output: 762345 (reversed value) Sum of all digits: 27 Example 2: Input: 14980 (add 1 to n such that n=14981.) Output: 18941 (reversed value) Sum of all digits: 23 27. There are N students in a class. Five quizzes were given and the weights of the scores are equal. Calculate the average of each of student and the class average. Calculate also the difference between each students average and class average. 28. 29. 30. Count and print the total number of ways to change a 500-peso bill. Use 100, 50, 20, 10 and 5 peso bill denominations. Read a positive integer less than 5,000 and determine its equivalent notation in Roman Numerals. Calculate and output the volume and area of spheres using the formula: V = (4PiR3)/3 A = 4PiR3 where R is the radius of the sphere, from 1 to 20.

31.

Using the equation Y=2+4X-X2, compute and output values of Y for values of X from 1 to 20, and in increment of . An object falling from rest in a vacuum falls 16 feet on the first second, 48 feet on the 2nd second, 80 feet on the third second, 112 feet the 4th second and so on. Output the distance traveled by the object after 15 seconds.

32.

33.

The digital root of a number, N, is the largest integer, K, such that K2 <= N. Accept a positive number as input and output the digital root of that number.

SERIES: 34. The value of S is computed from the formula:

S = 1 + 1/2 + 1/3 + 1/4 + 1/5 + + 1/N Output the number of terms required and the value of S before S exceeds 3.1. Example: 1st term: S = 1; 2nd term: S = 1 + 3rd term: S = 1 + 4th term: S = 1 + 5th term: S = 1 + ... nth term: S = ? 35. 36. 37. 38. Print 1 4 1/2 1/2 1/2 1/2 = + + + 1.5; 1/3 = 1.8333; 1/3 + 1/4 = 2.08333; 1/3 + 1/4 + 1/5 = 2.2833;

7 ... between 1 and 150.

Output the set of numbers in the series 1 2 4 7 11 16 until 211 is reached. Print a table of the numbers 1 through 10 in increments of 1/2,1/3, 1/4 and 1/5. A ball is dropped from an initial height of 50 feet. If the ball bounces 2/3 of the previous height, make a program that will calculate and print the total distance traveled by the ball after the 10th bounce. Determine how many even numbers must be added together before the sum is greater than 100. The formula to compute the allowable load in pounds of a column are: S = 17,000 0.435R2 for R < 120 and S = 18,000/[1+(R2 / 18,000)] where: S is the allowable load L is the length of pipe M is the section modulus R is the slimness ratio which equals the length of a column divided by the section modulus.

39. 40.

ARRAYS: 41. Store all elements of a 1-dimensional array of numbers in the memory. Output the following: a) Sum of the list b) Average of the list c) The biggest element d) The smallest element e) The median Develop an algorithm that would perform the following routines: 1) Store N digits as the elements of a 1-dimensional array. 2) Print the original array.

42.

And the sorted elements in: 3) Ascending order 4) Descending order. Output the original array and the sorted lists. 43. Develop an algorithm that would perform the following routines: 1) Read in N integers as elements of a list. 2) Accept a digit and remove it from the list 3) Accept a digit and its subscript. Include that input in the list by inserting that digit in the specified place. It is necessary to adjust the other elements. Use choices in a menu. 44. 45. Store 10 digits as the elements of a 1-dimensional array. Accept a digit and search it in the array. Output the subscript of the element. Read and output elements of a 2-dimensional array. Make a menu for choices to perform the following routines: 1) 2) 3) 4) 5) 6) 7) 8) 9) 46. Elements are read rowise. Elements are read columnwise. Output the sum of each row. Output the sum of each column. Output the sum of all the elements. The biggest element in each row The smallest element in each column. The biggest element in the array. The smallest element in the array.

Read in a word and output as specified. Example 1: Word : MADAM Output : The word is a palindrome The reverse is the same There are 5 letters and has 2 vowels Example 2: Word : UNIVERSITY Output : The word is not a palindrome The reverse is YTISREVINU There are 10 letters and has 4 vowels There are two lists of numbers. Create a resultant elements are the sum of the elements of the two lists. Example: List A List B List C 2 3 5 5 1 6 Read in the elements of a list. Create a resultant elements is N more than each element of the given list. list whose

47.

48.

list

whose

49.

Given a 5x5 matrix, output the following: use choices. 1) 2) 3) 4) 5) sum all all all all of the diagonal. the elements above the elements below the elements above the elements below the the the the diagonal diagonal diagonal diagonal (upper (upper (upper (upper left to lower right). left to lower right). right to lower left). right to lower left).

50.

Develop an algorithm that would read in 2 list of numbers and would perform the following using theories on sets: (use choices) 1) The union of the sets. 2) The difference of the sets. 3) The intersection of the sets.

Вам также может понравиться