Documente Academic
Documente Profesional
Documente Cultură
This paper consists of SIX (6) questions. Answer any FOUR (4) questions in the answer booklet
provided. All questions carry equal marks.
Question 1
Develop a C Program for the following scenario. Cashier will enter the product and the quantity
which purchased by the customer. The program will display product name, the price of the
product and total payment that need to pay by the customer.
Sample Output:
(25 marks)
CSC2203(F) Page 2 of 6
Question 2
a) The function below uses selection sort algorithm to sort a set of 10 integer data that are
stored in an array. Complete the function.
int i,j,temp;
if ( _______<3>___________ )
______<4>_________ ;
_________<5>_______ ;
________<6>__________ ;
}
(13 marks)
b) Trace the following program and produce the output.
#include <stdio.h>
main()
{
int x = 10, y = 20;
int z;
z = ++x + y--;
printf(\nx = %d y = %d z = %d,x,y,z);
++x;
z = x++ + y--;
printf(\nx = %d y = %d z = %d,x,y,z);
}
(12 marks)
CSC2203(F) Page 3 of 6
Question 3
#include <stdio.h>
void getSum(int);
void getMul(int);
float getAverage();
void main ()
{
int number1, int number2 , int number3, sum,avg,mul;
(20 marks)
Question 4
Student Name
Stuednt Id number
Faculty
Semester
Answer the following questions based on the information contained in the above form.
c) Write a function to enter values for the array of structures declared in (b).
(6 marks)
d) Write a function that will display the players name who are from the FOSTEM
faculty.
(11 marks)
.
Question 5
a) Write a function that will receive an array of 10 integer values and one integer type of
data that represents the data to search. The function will return the location where the
integer data was found in the array. If the data is not in the array, the function will
return a -1.
(8 marks)
CSC2203(F) Page 5 of 6
i)
#include <stdio.h>
main()
{
int x = 28, y = 5;
while( x > y)
{
printf("\nx = %d",x);
x-= 5;
while ( x > 15)
--x;
printf("\nx = %d",x);
}
(12 marks)
ii)
#include<stdio.h>
void swap(int , &int);
main()
{
int x = 10, y = 28;
swap(x,y);
printf(\nx = %d y = %d,x,y);
}
Question 6
a) Write a program that will convert a celsius to fahrenheit. The program should have a
function that will receive the celsius value and returns the equivalent Fahrenheit
value.
(8 marks)
c) Using the conditional operator (? :), write a program that will determine if a number
entered by the user is a positive number or a negative number.
(6 marks)