0% found this document useful (0 votes)
31 views4 pages

Cosc 101 111

Gg

Uploaded by

Rage Marcus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Cosc 101 111

Gg

Uploaded by

Rage Marcus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

BABCOCK UNIVERSITY

ILISAN-REMO, OGUN STATE, NIGERIA.


SCHOOL OF COMPUTING AND ENGINEERING SCIENCES
Final First Semester Examination SESSION: 2018/2019
COURSE: COSC101/COSC111-Introduction to Computer Science and Programming I
LECTURERS: Prof. Idowu S. A., Adekola O. D., Akande O., Ebiesuwa O.
INSTRUCTION: Answer ALL questions in Section A and Three (3) questions in Section B
1.Three basic types of programming language are 13.Write the following expression in C language acceptable
----------------------------------, --------------------- and format:

-----------------------

2.List the three main classes of computers


14. Elements in an array are identified by a unique:
a)data type b)index
3.C programming language is an example of which type of
language and was developed by ------Dennis Ritchie----- at -----
Bell----- laboratory in the year ---------1972----
15. Write a C statement that uses an array to keep the
score of 5 students in 3 courses
4. Identify invalid variables in the following and why? int score[5][3];
i)2_myname ii) char iii)total_cost iv)int-Amt v) acct numb

16. Which logical unit of the computer retains information?


5. The preprocessor directive used in defining a symbolic
constant in C programing is ---------------------------

a).#include b).#define 17. Identify and correct the error(s) in each of the following:
int x = 1, total;
6. T/F. Comments are executable by the compiler. False while ( x <= 10 ) {
total += x;
7. What happens if a compiler encounters the following
++x;
statement: // printf(“\n This is solvable”);
}

8. In a program, dividing a value by zero is what type of error?


18. What does the following program print? If no output,
then fix the error!
9. Write a C program to display your name, date of birth. and
mobile number in the following form int main()
Name : John James {
DOB : August 25 ,1980
int y, x = 1, total = 0;
Mobile : 09091234573
while ( x <= 10 ){
10. What will be the output of the following code if age is i. 16 y = x*x;
ii.14
printf(" %d \n", y);
#include<stdio.h>
total += y;
int main(){
int age;
x++;

printf(“Input your age \n”); }

scanf(“%d”, &age); printf("Total is %d”, total);


if (age>=16) return 0;
printf(“Print admission letter”); }
Answer I. Print admission letter 19. Write a C program that takes hours and minutes as input,
II. No output and calculates the total number of minutes

11.What is the output of the following code if number of lines Expected Output :
input is 5?
Input hours: 5
#include <stdio.h>
Input minutes: 37
int main() {
Total: 337 minutes
int n, i;
printf("Input number of lines: ");
scanf("%d", &n);
20.Define an array called “Numb” to store the first 10 natural
for(i = 1; i <= n; i++) {
numbers. Do the following:
printf("%d %d %d\n", i, i*i, i*i*i);
i).Write two statements to display the first and the last elements
}
ii).Suppose sum = Numb[0]+Numb[3]. What is sum+=Numb[5]?
return 0;
}
12. Use while loop to re-write this code:

int factorial ( int n) {


int i, x =1;
for (i =2; i <= n; i++)
x ∗= i;
return x ;
}

Q
Section B (Answer any Three (3) Questions

1(a). There are four ZONES- West, East, North and South. Write a C program to read the age and the state of a
candidate, then determine whether he is eligible to vote. If eligible then display “Good To Vote-Congratulations”
otherwise display “My Friend TOO YOUNG TO VOTE Sorry!!. You can vote only after 18 years of AGE”.

Rules: If you are above 18 and from the WEST, EAST and SOUTH then you are eligible to vote otherwise not
eligible, if you are from the NORTH and of age less than 18 but greater than 14 then you can vote.
8mks

(b)(i) Write a C program that accepts principal (P), rate of interest(R), time(T) and compute the simple interest.
PRT
Given that ∫amt ¿ 100 . 6mks

(ii) Write a program in C to store elements in an array and print them out. 6mks

2(a).List in an ordered form the steps to be followed during development of a computer program to solve a problem.
. 5mks

2(b)(i). Consider the following code and debug for successful compilation: 5mks
//Program …
#include <stdio.h>
int main()
{
int n;
printf(“Value\n”);
scanf("%d", &n);
if(n%2==0);{
printf("\t The result : %d", n);
}
else{ printf("\t The result is not: %d", n); }
}
}
2(b)(ii) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several
tank-full of fuel by recording kilometers driven and liter used for each tank-full. Develop a C program that allows
user to input the kilometer driven and liter used for each tank-full. The program should calculate and display the
kilometer per liter obtained for each tank-full. After processing all input information, the program should calculate
and print the combined miles per gallon obtained for all tank-full. To terminate processing you can enter -1 for
number of liters used. 10mks

3(a). Write a C program that reads an integer between 1 and 12 and print the month of the year in English 8mks

b).For a new student in Babcock University to be fully registered and allocated a room in a hall the student must
fulfill the following dependent conditions. 4mks
--must have letter of admission
--must have paid school fees and get financial approval.
--complete online registration and have course form
--lastly must have an ID card
i).With the use of nested-if develop an algorithm to simulate this process.
ii).Study the following program and answer the following questions:

a).What is the purpose of the program? 3mks


b).Identify the errors in the following program and fix 5mks

#include <stdio.h>
/* height and width of a rectangle in inches */
int width;
int height,
int area; perimeter;
int main() {
height = 7;
width = 5;
perimeter = 2x(height + width);
printf("Perimeter of the rectangle = %d inches\n", perimeter);
area = height x width
printf("Area of the rectangle = %d square inches\n", area);
return(0);

4(a)(i)Define a function and give two advantages of functions. 4mks

(ii). Write a program in C to show the simple structure of a function 6mks


(iii)Write a program in C to find the square of any number using the function 5mks

b) Write a C program that accepts an employee's ID, total worked hours of a month and the amount he received per
hour. Print the employee's ID and salary (with two decimal places) of a particular month. 5mks

=================================

You might also like