Вы находитесь на странице: 1из 10

INDEX NO: _____________

AIMST UNIVERSITY

February 2015 Mid Semester Examination


Academic Session 2014/2015
Faculty of Business and Management
BMIS 1121 INTRODUCTION TO PROGRAMMING
Date: 13 April 2015

Time: 2:00 4:00 p.m


(2 Hours)

Instructions to Candidates
1. Please ensure that this question paper consists of EIGHT (8) printed pages, excluding
the cover page, before you start the examination.
2. You will have 10 minutes to read the paper. Do not start writing until you are told to
do so.
3. This paper consists of two (2) sections A, B and C :
Section A (Multiple Choice Questions) (15 marks)
Answer ALL questions and answer in the answer book.
Section B (Short Answer Questions) (30 marks)
Answer ALL questions and answer in the answer book.
Section C (Long Programming Questions) (15 marks)
Choose any ONE (1) question and answer in the answer book.
4. Work that you consider incorrect should be crossed out with a single line but should
not be erased or rendered unreadable.
5. Use only black or blue pen for all work other than graphs and diagrams, which may be
done in pencil.
6. Do not remove any question/answer booklet from the Examination Hall.
7. You are allowed to use a silent, non-programmable calculator for your work. All
workings must be shown.
8. Tie the question paper on top of the answer booklet.

BMIS 32132

INDEX NO: __________

MULTIPLE CHOICE QUESTIONS [15 MARKS]


SUGGESTED TIME: 20 MINUTES
Instructions to candidates: Answer ALL questions and answer in the answer book
provided.
1.

Semantics is ____________.
A. the meaning of the language within a given context
B. the rules to join words together in forming a correct expression or phrase
C. function to tell computer what to do
D. instructions for computer to do task

2. 1 - Specification of needs
2 - Problem analysis
3-X
4- Implementation
5-Y
6- Documentation
The above lists are the steps in Software Development Methods (SDM). What are X and
Y?
A.
B.
C.
D.

Pseudocode Design, Checking


Module Writings, Testing
Algorithms Design and Representation, Testing and Verification
Function Design, Verification

3. Which statement is FALSE about algorithm?


A. Algorithm must be general and cannot be ambiguous.
B. Algorithm must be arranged in sequence and can solve the intended problem using the
resource currently available on the computer.
C. Algorithm can be represented using flowchart and coding.
D. Algorithm must have inputs and outputs.

[This paper consists of 5 pages excluding the cover page]

BMIS 32132

4.

INDEX NO: __________

start

w
end
What is the meaning for the flowchart symbol labeled as w above?
A.
B.
C.
D.

Process
Calculation
Selection
Terminal

5. Select the CORRECT steps to write a C program.


A. Editing, compiling, linking, executing
B. Editing, linking, compiling, executing
C. Editing, compiling, loading, executing
D. Editing, compiling, linking, executing
6. Choose TWO (2) symbols used in writing comment in C.
A.
B.
C.
D.

/*
/*
/*
/*

*/ and//
/* and \\
/* and //
*/ and \\

7. Choose the valid variable definition for age of kid that is 7 years old.
A. age = 7;
B. int kid age = 7;
C. int HowOld = 7;
D. int 7age=7;
8. What will be the output of the following C code fragment?
. . .
a = 52;
printf("a is %d", a);
printf("a is %d\n", a-- - 3);
. . . a is 52 a is 48
A.

B.

a is 52 a is 49

switch(num){
C.
a is 52 a is 52
case 0 :
D.
case 2 error
:
case 4 :
9. What
will6 be
case
: the output of the following C code fragment if user entered 1?
case 8 : printf(even\n);
break;
case 1 :
[This paper consists of 5 pages excluding the cover page]
case 3 :
case 5 :
case 7 :printf(odd\n);

BMIS 32132

A.
B.
C.
D.

INDEX NO: __________

Error
odd
even
Nothing is printed

10. Using && operator will result to True if __________


A. all conditions are true
B. one of the condition is true
C. none of the condition is true
D. at least one of the condition is true

11. The below statements describes


How many times this loop
will iterate is determined by
the programmer during code
writing.
A.
B.
C.
D.

sentinel-controlled loop
counter-controlled loop
infinite loop
for loop

12. How many times the iteration happen for the following code?
#include<stdio.h>
int main()
{
int i=5,j=2,count=0;
j=i%j;
do
{
i++;
count++;
}while(i<j);
printf("Total loop is %d\n",count);
return 0;
}

[This paper consists of 5 pages excluding the cover page]

BMIS 32132
A.
B.
C.
D.

INDEX NO: __________

1
2
5
Infinite loop

13. __________ will tell the compiler that there exist a function with this name defined
somewhere in the program.
A. Function definition
B. Function prototype
C. Function call
D. Function prototest

[This paper consists of 5 pages excluding the cover page]

BMIS 32132

INDEX NO: __________

14. _____________ is variable that is declared in the formal list of the function header.
A. Global parameter
B. Local parameter
C. Formal parameter
D. Actual parameter
15. After leaving the function, these variables are destroyed. When the function is called
again, they will be created (reassigned). What is the type of this variable category?
A. Actual variable
B. Formal variable
C. Global variable
D. Local variable
E.

[This paper consists of 5 pages excluding the cover page]

BMIS 32132

INDEX NO: __________

STRUCTURED QUESTIONS [25 MARKS]


SUGGESTED TIME: 30 MINUTES
Instructions to candidates: Answer ALL questions.
QUESTION 1
Write a single C statement corresponding to each of the following tasks:
i.

Declare the variables weight and height as floating-point variables.


[1 Mark]

ii.

Declare the variable counter as an integer variable with an initial value of 0.


[1 Mark]

iii.

Compute the value of new_weight as the difference of the value of weight and the
value of weight_loss.
[1 Mark]

iv.

Add 1 to the value of counter and store the result in counter.


[1 Mark]

v.

Print the following message using ONLY 1 printf() statement.


1. Introduction to
2. C Programming

[1 Mark]
QUESTION 2
Rewrite the following code segment as an equivalent segment that uses a for statement.
[5 Marks]
product = 1;
next = 1;
while (next <= m) {
product = product * next;
next = next + 1;
}

[This paper consists of 5 pages excluding the cover page]

BMIS 32132

INDEX NO: __________

QUESTION 3
Based on variable declarations and program fragment below, trace and write the output.
[5 Marks]

int a =3, b=5, c= 4;


printf(%d %d \n, --a, ++b);
a = ++c;
b += a++;
c *= --b;
printf(%d %d %d \n, a, b, c);

QUESTION 4
Write the following statements in C:
i.

if (x + y) is not equal to 100 and b is greater than or equal to 200


[2 Marks]

ii.

if (a + b) is less than or equal to 1200 or (a b) * 4 is equal to 600


[3 Marks]

QUESTION 5
#include<stdio.h>
intmain()
{
intmarks;
printf("Entermarks:");
scanf("%d",&marks);//getmarks
if(marks>50)//ifmarks>50displaymessage
printf("Youhavepassedtheexam!");
return0;
}

Modify program above, so that it displays two messages You have failed the exam! and
Please study to improve your grade, if marks are less than or equal to 50.
[5 Marks]
QUESTION 6
Writeafunctiondefinitionforthefollowing:
i.

Afunctionthatdividestwonumbersandreturnstheremainder.

ii.

[3Marks]
AfunctionthatprintsanATMmenutodisplayselectionsuchaswithdrawal,transfer
andbalancechecking.
[2Marks]
[TOTAL MARKS 20]
[This paper consists of 5 pages excluding the cover page]

BMIS 32132

INDEX NO: __________

STRUCTURED QUESTIONS [15 MARKS]


SUGGESTED TIME: 20 MINUTES
Instructions to candidates: Choose any ONE question and answer in the answer book
provided.
QUESTION 1
Write a program using function to convert the temperature in Fahrenheit to Celsius or
Fahrenheit to Kelvin unit. You have to create to separate functions and allow user to select to
convert either F to C or F to K. The formulas for the conversion are as follows:
Fahrenheit to Celsius - T(C)
Fahrenheit to Kelvin -

= (T(F) - 32) 0.556

T(K) = (T(F) + 459.67) 0.556

If users, let say select F to C, the function to convert Fahrenheit to Celsius will be called. See
sample program to do your program.
Welcome to Fahrenheit Conversion Calculator.
Please enter the temperature in Fahrenheit:
200
Please select the conversion type:
1 to convert Fahrenheit to Celsius
2 to convert Fahrenheit to Kelvin
2
60 Fahrenheit is equal to 288.71 Kelvin

[15 Marks]
QUESTION 2
Write a program that takes three float values of student marks and total up them. The function
total will add up all three marks and one function grade is call to print out the message
Youre passed!, if the total marks greater or equal to 50, otherwise the message Youre
failed! is printed. See the sample output given below.
Please enter three marks for quiz, test and assignment:
20 20 60
Your total marks is 100.00
Youre passed!

[15 Marks]
ooo0ooo
[This paper consists of 5 pages excluding the cover page]

BMIS 32132

INDEX NO: __________

[This paper consists of 5 pages excluding the cover page]

Вам также может понравиться