Computer Programming Worksheet I 2022 (3)
Computer Programming Worksheet I 2022 (3)
1
Express following algorithms using:
9. Develop an algorithm that accepts your mark out of 100 for Computer Programming course
and prints its corresponding letter grade based on the scale indicated below.
2
10. Develop an algorithm that displays the sum of the first N numbers odd numbers where N is
an integer to be read from the keyboard.
11. An algorithm that returns the Celsius value for a given temperature measured in Fahrenheit.
(For example, the input 68 would output 20 use the conversion formula 5(F-32) = 9C.
12. An algorithm that converts a given number of inches to centimeters. (1 inch = 2.54 cm).
13. Determine whether an input is number is prime or not.
14. An algorithm inputs accepts two integers and then prints the sum, difference, product,
quotient, and remainder of two integers
15. Write an algorithm that accepts the constants of the quadratic equation and calculate the root
of the equation.
16. An algorithm calculates the factorial of any positive number n.
17. An algorithm calculates the sum of the first n factorials.
Sum = 1!+ 2!+ 3!+…. (N-1)!+N!
18. An algorithm Calculate the first n Fibonacci Series.
N.B. A Fibonacci sequence is a series whose first and second series is one and subsequent
series element is determined by the sum of the preceding two series elements.
Partial list of the series: 1,1,2,3,5,8,13,21,34……….
In general F1= F2=1
Fn=Fn-1 + Fn-2 for n >2
7.1 1 ½ ¼ …………………
7.2 1 2 4 16 32 ………………..
7.3 54321012345
20. An algorithm reads in n real quantities and displays their sum and average.
21. An algorithm for raising a number n to a power p . Note raising a number n to a power p is
the same as multiplying n by itself p times.
22. An algorithm to print all prime numbers between 1 and num where num is an integer value
less than or equal to 1000.
23. Write the algorithm which computes N! Using flow chart.
Note n! =n*n-1*n-2*…2*1
3
24. Write the algorithm that computes area and perimeter of a rectangle using flow chart.
25. Write the algorithm that finds the minimum of three numbers using flow chart.
26. Write the algorithm that finds the first n odd numbers.
27. Express a given number of seconds in terms of hours, minutes and seconds.
Hint: