You are on page 1of 9

www.vuplanet.

com

MIDTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one

C language is developed by

► Bill Gates

► Robert Lafore

► Dennis Ritchie

► Deitel & Deitel

Question No: 2 ( Marks: 1 ) - Please choose one

Which of the following choice is not an example of an int data type?

►0

► -32

► 65531

► -4.0

Question No: 3 ( Marks: 1 ) - Please choose one

In flow chart, the symbol used for decision making is,


► Rectangle

► Circle

► Arrow

► Diamond
Then draw a line to its right
www.vuplanet.com

and use the decision symbol i.e. diamond diagram. Pag no 51


Question No: 4 ( Marks: 1 ) - Please choose one

Switch statement deals with,

► Integer data only

► float data only

► character data only

► Integer and character data

Question No: 5 ( Marks: 1 ) - Please choose one

Default case in switch statement is,

► Must

► Optional

► syntax error

► Necessary
The default statement is optional. If
there is no case which matches the value of the switch statement, then the statements
of default are executed pag no 68

Question No: 6 ( Marks: 1 ) - Please choose one

*.doc is _____________ by type.


.

► Sequential File

► Random Access File

► Data File
www.vuplanet.com

► Record File

Question No: 7 ( Marks: 1 ) - Please choose one

Member function tellg() returns the current location of the _____________ pointer.

► tellptr()

► write()

► seekg()

► get()

Question No: 8 ( Marks: 1 ) - Please choose one

s
Dealing with structures and functions passing by reference is the most economical method

.
► True

► False

Question No: 9 ( Marks: 1 ) - Please choose one

In C/C++ all character strings are terminated with,

► Null character
www.vuplanet.com

► String

► Zero

► Full stop
.

Question No: 10 ( Marks: 1 ) - Please choose one

Word processor is .

► Operating system

► Application software

► Device driver

► Utility software

Question No: 11 ( Marks: 1 ) - Please choose one

Which of the following can not be a variable name?

► area

► _area

► 10area

► area2

Question No: 12 ( Marks: 1 ) - Please choose one

Which looping process is best, when the number of iterations is known?


www.vuplanet.com

► for
► while

► do-while

► all looping processes require that the iterations be known

Question No: 13 ( Marks: 1 ) - Please choose one

By default an array of characters is passed by value to a function,

► True

► False

Question No: 14 ( Marks: 1 ) - Please choose one

Which of the following operator is used to access the address of a variable?

► * operator

► -> operator

► && operator

► & operator

Question No: 15 ( Marks: 1 ) - Please choose one

The name of an array represents address of first location of array element.


www.vuplanet.com

► True

► False

Question No: 16 ( Marks: 1 ) - Please choose one

Let suppose .

Union intorDouble{
Int ival;
Double charvar;
};

main(){
intorDouble VAZ;
int size ;
size = sizeof(VAZ);
}

What will be the value of variable "size", if int occupies 4 bytes and double occupies 8 bytes?

12

Question No: 17 ( Marks: 2 )

What is the difference between for loop and while loop?

for loop runs till the condition end and while loop runs until condition is not completed

Question No: 18 ( Marks: 2 )


www.vuplanet.com

Consider the structure .

struct Customer
{
int custnum;
int salary;
float commission;

Customer.salary = cust1;
cust1=2000;
};

A programmer wants to assign 2000 for the structure member salary in the above example of
structure Customer with structure variable cust1 What line of code should he write

Question No: 19 ( Marks: 2 )

When a pointer is incremented then how many bytes will it move to change its address?

Question No: 20 ( Marks: 3 )

If there are 2n elements in an array then what would be the number of iterations required to
search a number using binary search and linear search?

Question No: 21 ( Marks: 3 )

Perform left shift operation on a binary number 0101 and write the result in binary and decimal.
5

Question No: 22 ( Marks: 5 )

What will be the output of following code segment?


void func(int [], int);
main(){
int arr[5] = {2, 3, 5, 6, 7} ;
www.vuplanet.com

func(arr, 5) ;

for (int i = 0; i<5; i++)


cout << arr[i] << “ ”;
}
void func(int a[], int size){
for (int i = 0; i<size; i++)
a[i] = 2*a[i];
}

Question No: 23 ( Marks: 5 )

What is random access file and how data can be read and write into random access file?
Now we will discuss how to access files randomly, forward and backward. Before moving
forward or backward within a file, one important factor is the current position inside the file.
Therefore, we must understand that there is a concept of file position (or position inside a
file) i.e. a pointer into the file. While reading from and writing into a file, we should be very
clear from where (which location inside the file) our process of reading or writing will start.
To determine this file pointer position inside a file, we have two functions tellg() and tellp().
Position in a File Let’s say we have opened a file stream myfile for reading (getting),
myfile.tellg () gives us the current get position of the file pointer. It returns a whole number
of type long, which is the position of the next character to be read from that file. Similarly,
tellp () function is used to determine the next position to write a character while writing into
a file. It also returns a long number. For example, given an fstream object aFile:
Streampos original = aFile.tellp(); //save current position aFile.seekp(0, ios::end);
//reposition to end of file aFile << x; //write a value to file aFile.seekp(original); //return to
original position So tellg () and tellp () are the two very useful functions while reading from
or writing into the files at some certain positions.
www.vuplanet.com

MIDTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one

C language is developed by

► Bill Gates

► Robert Lafore

► Dennis Ritchie

► Deitel & Deitel

Question No: 2 ( Marks: 1 ) - Please choose one

Which of the following choice is not an example of an int datatype?

►0

► -32

► 65531

► -4.0