CS201 Introduction to Programming
Mid Term Examination – Spring 2006
Time Allowed: 90 Minutes
Please read the following instructions carefully before
attempting any of the questions:
1. Attempt all questions. Marks are written adjacent to each
2. Do not ask any questions about the contents of this
examination from anyone.
a . If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b . If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve
c . Write all steps, missing steps may lead to deduction of
d. All coding questions should be answered using the C++
You are allowed to use the Dev-C++ compiler to write and test
your code. If you do so please remember to copy and paste your
code into the examination solution area. (Do NOT share your
code; your colleague could get higher marks than you!!)
**WARNING: Please note that Virtual University takes serious note of
unfair means. Anyone found involved in cheating will get an `F` grade in
Question No. 1 Marks : 10
Write the function definitions for the following:
a) A function test() that would take three integer values x , yand z (as
parameters), find the largest and return the result to the calling function.
b) A function sum() that would take the one integer array myArray[ ] of size 10
(as parameter), calculate the sum of the elements of myArray[ ] and display
Note : The function sum() returns no value.
Question No. 2 Marks : 6
Write a program that will create and display the following series:
65, 44, 27, 14, 5, 0, -1, 2, 9, 20.
The series is created by the formula 2x 2 – 3x
for x=-5 to 4
The variable x is of type integer.
Question No. 3 Marks : 2
The value of 2*15/3*7+3*2 is
Question No. 4 Marks : 2
Carefully analyze the following lines of code and chose the correct option.
ch1 and ch2 are strings
ch1 is string and ch2 is character
ch2 is string and ch1 is character
ch1 and ch2 are characters
Question No. 5 Marks : 2
The size of a double variable is
Question No. 6 Marks : 2
An array is also called
an array variable
Question No. 7 Marks : 10
What will be the output of the following programs?
unsigned short x = 1;
for (int i = 0; i < 10; i++)
cout << x << endl;
x = x << 1;
unsigned short x = 1024;
cout <<x << endl;
x =x >> 1;
Question No. 8 Marks : 6
Calculate the following expressions for
x=3 and y=2