BABCOCK UNIVERSITY
ILISHAN-REMO
SCHOOL OF COMPUTING SCIENCE AND ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE
DEGREE EXAMINATION, FIRST SEMESTER 2014/2015
COSC 101: Introduction ~o Programming in C 3Credits (CT/CS/CIS/IRM)
EXAMINER: Mrs Bola Akande and Mr Rotimi Seton Total Marks: 60%
Time Allowed: l hr 30 mins Departments: CT, CS, & CIS
INSTRUCTIONS: Answer All questions in Section A and Band two questions in
Section C
SECTIONA -
Instructions: Fill in the gaps with the appropriate answers. (l O marks)
I. What does the acronym IDE stands for?
2. Write out the syntax for declaring a variable in C programming language
4.
3. -Two types of programming methodologies in use today are _______ and
To write any code you must start with a
--------- 5. A C program will start
execution from ______ function
6. Programming errors can be grouped as , and ____ _
7. C is a weakly typed langu_age (True/False)
8~~Tlanguage was.written by - - · - ,,,,,_ · of- · - -.., laboratory
-~-- - ---- 9. There are ,
Keyworos iniC- - --=-- .c-.c____""" ___ , 10. What is a variable? - -_ ~-~ ~ ·-- ·
·-,~----- .:::::::::_··:·.-:... ·.~
8
- ...... ~- • : --- - -----.;:_. 5zB~£bR ¼ -- _,_ IC a· .. !l)~ C{!.;:_!!!;£..~ c:- fo; &I¢ z-.c::;.:z:µse - , ..
Instructions: Iden tify the errors and correct the following C program codes ( 10 marks)
/nested if example
#include<stdio>
mannO
{
int payment, registration;
printf("Welcome to this dummy meal ticket portal. \n")
printf{"Use I to indicate YES and O to indicate NO\n");
p1intf("Have you paid your school fees? :\n");
scan ("%d", &payment);
' if(payment = I);
{
printf{ Have you completed your registration? :\n");
scanf("%d", ®istration);
if (registration = I)
printf("Here is your meal ticket");
else {
printf ("you have to finish your registration first");
else (
Printf ("You cannot register without
paying your fees ");
SECITONC
Instructions: Answer any 2 questions from this section (20 marks each)
1. A trader needs to automate the computation of bill to each customer based on the
quantity of item sold to each customer and the cost per one item. You are to design a
mini application that will allow you to: j '_ \
a Specify cost per an item '
b. Specify the quantity of item bought
c. Compute the amount paid for that item
d. Print out the amount to be paid by individual customer
e. Thus you are expected to do the followings:
Understand and analyze the problem indicating: input data, output data, and
processing requirement (5 marks)
Draw the flowchart (5 marks)
Implement your flowchart using_C programing language (10 marks)
(Hints: Using appropriate control structure each customer will receive bill for .=
RIO'DJent. The number of daily customer is not known in advance) .oaumc~'m.f<,;7
. ff 1ti J.t'JiM,.t!I - eac -c g~ wSca.::,A,.C, - -· D, E,or r=i:-uu an:
ask_?! to design an application which alcf new studeiits k cletermirun~eir grade,41._ ___
each course based on their score. The application should be able to: · a Allow input of
score
b. Determine the grade based on score
c. You are therefore expected to:
d. Determine the input data, output data, and the processing requirements
(3) e. Draw the flowchart for the compound if-else-if (3)
f. Using compound if-else-if statement design Babcock grading system with
C language (7)
g. Convert the above compound if-else-if statement into switch case structure with
C language (7)
grade E, and 39 and below b grade F)
3. A woman sells recharge cards of four different network (Glo, MTN, CelTel, and
Etisalat). Each network has different price ratings. For the .woman to sell the right card
she needs to first ask her customer for the network they desire, then ask for how much
they needed. Thus a customer will need to choose from any of the {our available network
and also choose the price from that particular network. The woman business expands and
she has more q"Lo M1