REPUBLIC OF CAMEROON REPUBLIQUE DU CAMEROUN
Peace-Work-Fatherland Paix-Travail-Patrie
MINISTRY OF HIGHER EDUCATION MINISTERE DES ENSEIGNEMENTS SUPERIEUR
FIRST SEMESTER EXAM
COURSE: PROGRAMING 1
OPTION: SWE1
Academic year 2024 DURATION: 2H30Min
Lecturer: Mr. SIMO BORIS
Question1
1. Define the following terms or expressions related to programming : 1mk x 4
a. Identifier b. Pointer c. Selection structure d. Repetition structure
2. Differentiate between a while loop and a do-while loop. 2mks
3. From what does a void function differs from a normal function ? 1mk
4. Clearly establish the difference between a Global Variable and Local Variable in C.
1mk
5. What is an array in C ? 1mk
6. What is the usefulness of constants in programming. Give the two different ways a
constant could be defined in C. 2mks
7. Differentiate between a syntax error and logical error in programming. 2mks
8. According to you what could be the usefulness of comments in coding ? 2mks
Question1
1. Sum of the Digits in an Integer
Develop a program that reads a four-digit integer from the user and displays the sum of
the digits in the number. For example, if the user enters 3141 then your program should
display 3+1+4+1=9.
2. Is it a Leap Year?
Most years have 365 days. However, the time required for the Earth to orbit the Sun
is actually slightly more than that. As a result, an extra day, February 29, is included
in some years to correct for this difference. Such years are referred to as leap years.
The rules for determining whether or not a year is a leap year follow:
• Any year that is divisible by 400 is a leap year.
• Of the remaining years, any year that is divisible by 100 is not a leap year.
Page 1|2
• Of the remaining years, any year that is divisible by 4 is a leap year.
• All other years are not leap years.
Write a program that reads a year from the user and displays a message
indicating whether or not it is a leap year.
3. Write a c program that will display the first natural number from 1 to 100
4. Write a c program frunction that will add two intergers of type int and display
the result of the addition
5. Is a Number Prime?
A prime number is an integer greater than 1 that is only divisible by one and
itself. Write a simple C program that will prompt the user to input a number and
determine whether it is prime or not. ( 8marks)
6. Write a c program that check if a number is even or odd .NB modulus operator
is required here
Page 2|2