Vu CS201 Introduction To Programming Mid Term Examination Solved/Unsolved Spring 2006

www.Educational.pk
CS201 Introduction to Programming
Mid Term Examination – Spring 2006
Time Allowed: 90 Minutes
attempting any of the questions:

1. Attempt all questions. Marks are written adjacent to each
question.
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
the problem.
c . Write all steps, missing steps may lead to deduction of
marks.
d. All coding questions should be answered using the C++
syntax.
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
this course.
Question No. 1 Marks : 10
Write the function definitions for the following:
www.Educational.pk
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
the result.
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.
Hint:
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
146
76
8 70
Question No. 4 Marks : 2
Carefully analyze the following lines of code and chose the correct option.
ch1=”a”;
ch2=’a’;
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
2 bytes
4 bytes
8 bytes
10 bytes
www.Educational.pk
Question No. 6 Marks : 2
An array is also called
an array variable
array declaration
struct
constant pointer
Question No. 7 Marks : 10
What will be the output of the following programs?
a) Program1
#include <iostream>
int main()
{
unsigned short x = 1;
for (int i = 0; i < 10; i++)
{
cout << x << endl;
x = x << 1;
}
return 0;
}
b) Program2
#include <iostream.h>
int main()
{
unsigned short x = 1024;
while(x>=1)
{
cout <<x << endl;
x =x >> 1;
}
return 0;
}

Question No. 8 Marks : 6
Calculate the following expressions for
x=3 and y=2
1) ++x++*++y
2) 3*++x+–y
3) ++x*4*++y