0% found this document useful (0 votes)
3 views

Programming I

The document is an examination paper for Programming I with C at Adara Institute, consisting of two sections: Section A with mandatory questions and Section B with optional questions. It covers fundamental C programming concepts such as preprocessor directives, variable declarations, control structures, arrays, pointers, and functions. The total marks for the exam are 30, with a time limit of 1 hour and 30 minutes.

Uploaded by

Azinwi Boris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming I

The document is an examination paper for Programming I with C at Adara Institute, consisting of two sections: Section A with mandatory questions and Section B with optional questions. It covers fundamental C programming concepts such as preprocessor directives, variable declarations, control structures, arrays, pointers, and functions. The total marks for the exam are 30, with a time limit of 1 hour and 30 minutes.

Uploaded by

Azinwi Boris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Adara Institute

Programming I with C - Level 100

Second Continuous Assessment Examination

Instructions:

 This paper consists of TWO sections.


 Answer ALL questions in Section A and ANY TWO questions from Section B.
 Show all your code clearly and provide explanations where required.
 The total marks for this paper are 30.
 Time allowed: 1 hour 30 minutes.

Section A (18 Marks) - Answer ALL Questions

Question 1 (6 Marks)

(a) Explain the purpose of the #include preprocessor directive in C. Give two common examples of
header files used with this directive and briefly describe what they provide.

(b) What is the difference between a variable declaration and a variable definition in C? Provide
a simple code example to illustrate both.

(c) Briefly explain the function of the printf() function in C. Give an example of how to print an
integer variable named count along with a descriptive label.

Question 2 (6 Marks)

(a) Write a short C program snippet that declares an integer variable age and uses an if-else
statement to check if the age is greater than or equal to 18. If it is, print "Adult"; otherwise, print
"Minor".

(b) Explain the difference between the while loop and the do-while loop in C. In what scenario
would you prefer to use a do-while loop over a while loop?

(c) What is the purpose of the return statement in a C function? What value does the main()
function typically return to indicate successful execution?

Question 3 (6 Marks)

(a) Define an array of 5 integers named numbers and initialize it with the values {10, 20, 30, 40,
50}. Write a C code snippet to print each element of the array using a for loop.

Page 1|2 Adara Institute


(b) What is a pointer in C? How do you declare a pointer to an integer variable named value?

(c) Briefly explain the difference between passing arguments to a function "by value" and "by
reference".

Section B (12 Marks) - Answer ANY TWO Questions

Question 4 (6 Marks)

Write a C program that prompts the user to enter two integer numbers. The program should
then calculate and print the sum, difference, product, and quotient (integer division) of these
two numbers.

Question 5 (6 Marks)

Write a C function called calculate_factorial that takes an integer as input and returns its factorial.
Include error handling to ensure that the input is a non-negative integer. In your main() function,
prompt the user to enter a non-negative integer, call the calculate_factorial function, and print the
result.

Question 6 (6 Marks)

Write a C program that reads characters from the user until the user enters the character 'q'.
The program should count and print the total number of characters entered (excluding 'q').

Question 7 (6 Marks)

(a) Explain the concept of a string in C. How are strings typically represented and terminated?

(b) Write a C program that prompts the user to enter a string and then prints the length of the
string using the strlen() function from the string.h library.

End of Examination

Page 2|2 Adara Institute

You might also like