Wollo University
Kombolcha Institute of Technology
Department: ______________________
Computer Programming (ECEg 1052) Assignment
Target group: 1st year pre-engineering students
Max Marks: 20%
1. Write a C++ program that compute 2n where, n is input from the user/keyboard.
2. Write a C++ program that can compute the letter grade of a student after accepting the student’s
mid and final mark. The program should only accept mid result [0-40] and final [0- 60]. If the data
entered violates this rule, the program should display that the user should enter the mark in the
specified range. The program is also expected to run until the user refuses to continue. Use the
following scale.
100 > X > 90 ----------------- > A
90 > X > 70 ------------------- > B
70 > X > 50 ------------------- > C
50 > X > 40 ------------------- > D
40 > X > 0 --------------------- > F
> 100 and < 0 -------------- > Invalid Input
3. Write a C++ code that computes the sum of the following series.
Sum = 1! + 2! + 3! + 4! + …n!
Note: The program should accept the number from the user.
4. A prime number is an integer greater than one and divisible only by itself and one. The first
seven prime numbers are 2, 3, 5, 7, 11, 13, and 17. Write a program that displays all the prime
numbers between 1 and 100.
5. Write a C++ program that accept a number and display the factor of that number.
6. Write C++ program using for, do-while, and while statements to compute the following sums
and products.
A. 1+2+3+…+100
B. 5+10+15+…+n
C. 2+4+6+…+n
D. 1*3*5*7…*20
7. Write a C++ program that will print the following shapes.
A. B. C. D.
* 54321 * *
** 4321 *** ***
*** 321 ***** *****
**** 21 ******* ***
***** 1 ********* *
8. Develop a calculator program that computes and displays the result of a single requested
operation.
E.g. if the input is
15 * 20, then the program should display 15 * 20 equals 300
If the operator is not legal, as in the following example
24~25 then the program displays ~ is unrecognized operator
As a final example, if the denominator for a division is 0, as in the following
Input: 23/0 then the program should display the following:
23 / 0 can’t be computed: denominator is 0