DEPARTMENT OF MATHS/STATS & COMPUTER SCIENCE
SECOND SEMESTER EXAMINATION 2012/2013 SESSION
COURSE CODE: CSC 3381
COURSE TITLE: COMPUTER LAB III A TIME: 1Hr 30mins.
INSTRUCTION: ANSWER ANY TWO QUESTIONS IN SECTION A. SECTION B IS COMPULSORY
1. a. What are data types? Using C or C++ syntax, declare variables of three different types.
b. What are Control Structures? Mention and discuss any two in C or C++.
c. Write a C or C++ function and main program to produce prime numbers to a given n.
2. a. What is an array? Declare an array of 30 characters and a pointer to the array in C or C+++.
b. Explain four keywords associated with data output in C/C++.
c. Write a C or C++ function and main program to produce the Greatest Common Divisor for any
given integers P and Q.
3. a. What are preprocessor directives? List five and state their uses.
b. Compare the use of scanf and cin in C and C++ respectively.
c. Write a C or C++ function and main program to produce the Factorial of any given integer n.
4. a. What are pointers? Declare a pointer to a char type variable.
b. Compare the use of printf and cout in C and C++ respectively.
c. Write a C or C++ function and main program to produce the Fibonacci numbers to any
given integer n. (where n>1)
1. Number and explain what each line of the code above does.
2. Discuss the kernel of the While loop with an execution frame.
3. What is the entire program doing?
4. Is this program a C or a C++ convention? Hence what changes would make it C or C++