0% found this document useful (0 votes)
45 views2 pages

Cosc101 Exam 16 - 17

The document outlines an examination for the Introduction to Programming in C course at Babcock University, detailing questions related to C programming concepts, syntax, and logic. It includes multiple-choice questions, coding tasks, and algorithm properties, focusing on practical programming skills. Additionally, it specifies a software project for calculating employee salaries and a simple calculator program for Grade I pupils.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

Cosc101 Exam 16 - 17

The document outlines an examination for the Introduction to Programming in C course at Babcock University, detailing questions related to C programming concepts, syntax, and logic. It includes multiple-choice questions, coding tasks, and algorithm properties, focusing on practical programming skills. Additionally, it specifies a software project for calculating employee salaries and a simple calculator program for Grade I pupils.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BABCOCK UNIVERSITY

ILISAN-REMO, OGUN STATE, NIGERIA.


SCHOOL OF COMPUTING AND ENGINEERING SCIENCES
COMPUTER SCIENCE DEPARTMENT

COURSE: Introduction to Programming in C (COSCIOl) SESSION: 2016/17·


LECTURERS: Joshua V.(PhD), Adekola Daniel, Akande Oyebola, Ebiesuwa Seun
FIRST SEMESTER EXAM (60%)

SECTION A (Attempt all) (20%)


1). How many times does the loop run? I 11). A while statement must not end with a
for G= 2;j <= n;j++) i semi-colon:
(a) lO(b)n (c) n-1 (d)n-2 (a) True (b) False (c) No idea (d) Maybe
2). Which one of the following is not a 12). A do ... while statement must end with a
primitive data type in C: semi-colon:
(a) float (b) array (c) char (d) int (a) True (b) False (c) No idea (d) Not really
3) Which of the following definition is(are) 13). Write only the prototype of a function
correct: named primeDetector which tests whether a
I) char color[3] = { 'R', 'E', 'D' } ; passed value is prime or not and returns Oor 1
II) char color[4] = "RED"; as its returned value.
III) char color[]= "RED"; Hint: The caller will use the returned "Oor l" to
IV) char color[3] = "RED"; confirm prime.
(a)I onl1(b) III only(c) I,11 and III (d) all
4). C program execution starts from 14) what happens to a line of code written after
(a) begin (b) class() (c) void (d) main() return statement ...................... ...... ......
5) Elements in an array are identified by a; 15). what is the output of the following code:
unique: (a). data type (b). variable I int a= 4;
I
(c) subscript (d) value int b = 3;
-- ·------- -------
... -- - - if(a == b) printf("This cannot be seen");
6). Consider the following statement: 16) State the difference between aju,ictio,i
int x = 7/2; what is the value of x: declared before the main function and the one
(a) 3.5 (b) 3 (c) 1 (d) 3.0 declared inside the main ............ .
7). At least, the do ... while(condition) 17) Consider the following function prototype:
construct characteristically execute in what ,,_ float average(int n,jloat x{ });
number of times: What is the correct way to call this. function
(a) 0 (b) 1 (c) n (d) n-1 '
8). what is control (flow) construct exhibited in l 8)what is the output if integer values 2 is
. the following lines of code and what is last received by variable c.hoice:
value ofx: scanf("¾d", &choice);
x = 5; switch(choice){
X =x + 2; Case 1: printf("\n Hey What's Up"); break;
X = X * 2; '-
Case 2: printf("\n It is cool to know"); br,A~ •
(a) 14 (b) 2 (c) 10 (d) 5 I
Case 3: printf("\n Coding is fun);break; ,
default: printf("\n Out of Range");
}//end of switch statement
9). A compiler caD, execute comment in a code: 19). Compiler can execute a pseudocode:
(a) True (b) False {c) No idea (d) Maybe (a) True (b) False (c) No idea (d) undefined
10). An if statemer must end with a semi- 20)Consider the following array definition:
colon: (a) True (b False (c) No idea (d) I think char school{ J= "B(lbcock ";
what element is in school[7l ... ........... .
SECTION B (Attempt question 1 and any other 3 questions) ·

I) a) Identify errors in the following line of code and indicate each erroi: as syntax error,
.,,.-- semantic error, and logical error. Indicate with line numbers.

; ;;,,,,,,m 1, d,bv1 ,,,,,


,,:,1,~#i 1, I • d• <s I di •, h>
, J} lu 1ten()
/f {
' S· x,y,1,agt;
:6 . 11 •• , ~;
a=x +y;
. ~• • I :1, 1145; Figure 1: A screenshot of
-:•~' =• /01 a code to be debugged
it j't.,Q'. ' //11/111 if, 1, 1d11/1 11,duts witk ,,, ,,,,,,,
fll'. l //lhlll ,r •• ,,,. ,, 16
:J:1.2,: ,,,.,,,.,-.,,, , .. , ·••");
~:ii 111111 "%1", ,.,,,;
r,ti 11 1, , , <=1 6l
'·'ts: pr I nt I ( • Ahi t t • st , 4• 11 "I ;
,16'..'l

b) State and explain four properties of an algorithm

2).A software is to compute the monthly takehome of Thus, you need to write a C program using function
all category of employees of an establishment. The technique that will:
employee taxation is bas.ed on the following
constraints: i. Allow input of two integers
- I ; -frbasic salary i~ less than'--orequal to NS000,5 % ot iL::--ereate ,_ four- functions - called' addition,
subtraction, multiplication, and division
basic salary is deducted as tax otherwise 8%
deducted. iii. Output the result of addition, subtraction,
• Also 10% of the employee gross pay should be multiplication, and division.
deducted as part of pension scheme.
• It is require that each employee pay slip should Using for-loops, write a C program to compute
contain employee number, name, total allowance, average score of 300 students in 400 level offering
tax, basic salary, gross pay and Net pay. Software Engineering. The program will
Analyze this problem by stating the input, processing 1. Take in scores of 300students
and output requirements and draw a flow chart ii. Find the sum of scores of all the students
showing the procedure for the implementation of this iii. Find the average score
software: J HJNTS: J

) a) Using function, write a C program to calculate


* Total allowances= Housing+ Transport the area of a circle by receiving the radius as input
* Gross Pay =Basic salary+ Total allowances from the user. (Use pi= 3,142).
* Net pay = Gross pay - (Tax+ pension)
b} Us~ a loop statement and output the elements in
J). Babcock University Staff School needs a simple the following array nan1ed temperature:
calculator programme that can aid Grade I pupils in float temperature[]= {1.0, 3.4, 2.5, 9.0, 7.5, 5.0, 4.0 };
learning simple arithmetic operations involvin~two,.
integers. The school Head teacher contacted you to
ckvelov a simnle annlicatioQ that for this purpose.

You might also like