MULUNGUSHI UNIVERSITY
Pursing the frontiers of knowledge
SCHOOL OF SCIENCE ENGINEERING & TECHNOLOGY
EGM 272-Introduction to computer
Programming
TEST 1
Duration: 24 hours
INSTRUCTIONS
1. This test has one section.
2. Write your student number, NRC number and Cell number on your answer script in this case your
Source code
3. There will be no need for a Report in this test.
4. Read through this TEST document entirely and make sure you understand all the requirements
necessary to successfully complete the test.
5. This work should be done individually, copying will not be tolerated.
6. Indicate the question number you have answered
7. Present readable and tidy work
8. Total marks for this test are 20 marks.
Rules:
I. This work should be done individually, copying will not be tolerated, if the work turns out
to be similar an investigation will be done and the author of the work will be [Link] no
author is found all students with similar work will be penalised.
II. The use of for Loops in this Test is forbidden, you are only allowed to use do-whiles and
while loops.
III. The use of a sentinel value is mandatory
IV. Hardcoding in this Test will not be entertained therefore you are required to write a
program that will work for any value within your problem set.
V. All values must be entered from the keyboard using scanf unless explicitly defined as a
limit value.
VI. Each student has been allocated a question make sure you solve the correct question
otherwise you will attract a grade of zero. See list of assignment below.
VII. Clarification of questions can be done through the e-learning platform on the forum.
List of questions for Students
Student No Question
201600343 1
201602215 2
201701081 3
201701219 4
201701228 5
201701869 6
201701988 7
201704003 8
201800694 9
201800735 10
201800878 1
201800999 2
201801080 3
201801288 4
201801477 5
201801642 6
201801833 7
201802033 8
201802471 9
201802738 10
201802766 1
201802784 2
201803015 3
201803266 4
201803328 5
201803351 6
201803364 7
201901528 8
201905179 9
201905621 10
1 Questions
1. Write a program in C to display natural numbers up to n and their sum.
e.g Test Data : 7
The Sum of Natural Number up to 7 terms : 28
After finding the sum divide the sum with all numbers leading up to the natural number n
except number 5.
2. Write a program in C to read 10 numbers from keyboard and find their sum and average.
If the sum is above 100 find its square root.
3. Write a program in C to display the cube of each number up to a given an integer n.
Except for number 7
4. Write a program in C to display the multiplication table of a given integer up to itself.
Except for number 7
5. Write a program in C to display the n terms of odd natural number and their sum .
Test Data
Input number of terms : 10
Expected Output :
The odd numbers are :1 3 5 7 9 11 13 15 17 19
The Sum of odd Natural Number up to 10 terms : 100
After finding the sum divide the sum with all numbers leading up to the maximum odd term
as in example above you would divide up to 19.
6. Write a program in C to make such a pattern like right angle triangle with a number
which will repeat a number in a row.e.g
1
22
333
5555
Except for number 4. Make sure that this triangle is of any size therefore you should be able
to enter the number of rows you want.
7. Write a program in C to make such a pattern like right angle triangle with number
increased by 1 up to number n.
1
23
456
7 8 9 10
The the program should also find the sum of each row.
8. Write a C program to calculate the factorial of a given number n.
If the factorial of a number is greater than 1,000,00,000 ,find the square root of the
value (Note make sure after you find the square root, round the number to the nearest whole
number)
9. Write a C program to check which numbers up to a given number n are proper dividers
of that number. E.g
N=6
Proper dividers are 1,2,3
10. Write a C program to determine which numbers up to n are prime or not.
If a number is a prime number find the square root of that number
2 SUBMISSION
Upload the C file which should contain comments about each line of code you wrote
explaining what the line is doing.
Submit on Moodle by the appointed date/time for the hand in, Late submission will not
be entertained once the portal closes and you have not submitted it will be regarded as a
missed Test.
Save your work in a Zip file formatted as “QuestionNumber_StudentNumber.Zip” and
submit it via Moodle.