-->

# CS201 Solved Subjective Midterm Paper 2011

### CS201- Solved Subjective Midterm Paper

Here is the Complete Collection of CS201 Solved subjective Midterm Paper of May/10/2011. You Can Also Download CS201 Solved Mid Term Papers, CS201 Short Notes, CS201 Lecture Wise Questions Answers Files, CS201 Solved MCQs, CS201 Solved Quizzes , CS201 Solved Mid Term Subjective Papers , CS201 Solved Mid Term Objective Papers From the Links given at the end of this Post.

### CS201 Solved Subjective Midterm Paper 2011

CS201 MIDTERM EXAMINATION - Lectures 1-22

### CS201 Midterm Paper Question No. 1:

( Marks: 2 )

What is the difference between switch statement and if statement.

1.if statement is used when we have to check two conditions while switch is a multi conditional control statement

2. SWITCH statement can be executed with all cases if the “break” statement is not used whereas IF statement has to be true

to be executed further.

### CS201 Midterm Paper Question No. 2:

( Marks: 2 )

Why we close a file after use?

To save our data stored on file. Also this process makes our program fast and reliable.

OR

You have finished with it. This is particularly important if you are writing to the file. The operating system does not switch on the

disk drive to write just a single character to the disk, rather it waits until it has a load to write and then writes the lots in one go.

### CS201 Midterm Paper Question No. 3:

( Marks: 2 )

A two-dimensional array has 3 rows and 4 columns. Write down the syntax to initialize first element of all

three rows of two-dimensional array with value 2.

int matrix[0][0]=2

int matrix[1][0]=2

int matrix[2][0]=2

### CS201 Midterm Paper Question No. 4:

Identify the errors in the following code segment and give the reason of errors.

main(){

int x = 10

const int *ptr = &x ;

*ptr = 5 ;

}

Int x=10….No ending semicolon.

*ptr=5... Declaring a pointer to constant integer. You cannot use this pointer to change the value being

pointed to.

### CS201 Midterm Paper Question No. 5:

Can you use an assignment operator to assign the value of one C-string to another?

Yes we can assign the one value of C-string to another using assignment operator. We can

assign the value of one string to another string through this method.

A[0]=B[0]

A[1]=B[2]

A[3]=B[3]

And we can assign the whole string to another C string using Assignment operator by using loops.

### CS201 Midterm Paper Question No. 6:

Why binary search algorithm is more efficient than the linear search algorithm?

Binary search algorithm is more efficient than liner algorithm because the arrays are sorted in asending or

desending order and we use “devide and conqrer” technique. In binary search each iteration reduces the

search by the factor of two but in the linear we have the same number of searches as we have the number of

elements.e.g,if we have array of 1000 elements the linear search will take 1000 iterations however binary

search will take max 10.

### CS201 Midterm Paper Question No. 7:

( Marks: 5 )

Write down the output of the code given below :

Hint:

Size of char is 1 byte

Size of int is 2 byte

Size of float is 4 byte

#include

union mytypes_t {

char c;

int i;

float f;

} mytypes;

int main(){

mytypes.c = 'H';

mytypes.i = 15;

cout << sizeof(mytypes)<

mytypes.i = 15;

mytypes.c = 'H';

cout << sizeof(mytypes)<

system("PAUSE");

return 0;

}

### CS201 Midterm Paper Question No. 8:

( Marks: 1 )

In Program commenting the code liberally is

It need to be self-contained and understandable. Comments should be placed liberally. The comments

should explain the logic, not the mechanics. Try to avoid fancy programming.

### CS201 Midterm Paper Question No. 9:

Which header file must be included while handling files?

Include

### CS201 Midterm Paper Question No. 10:

( Marks: 1 )

What is meant by C++ statement: const int *ptr = &x;

ptr is a pointer to data of type const int type. And to assign the address of x to pointer ptr

### CS201 Midterm Paper Question No. 11:

( Marks: 2 )

What is a truth Table?

We know the concept of truth table. The truth tables are very important. These are still a tool available for

analyzing logical expressions. We will read logic design in future, which is actually to do with chips and

gate. We find it difficult to evaluate a complicated logical expression. Sometimes the logic becomes

extremely complicated so that even writing it as a simple syntax statement in any language. These are used to

make a big circuit with the use of minimum chips. These minimization techniques deal with Boolean algebra i.e.

logic.

### CS201 Midterm Paper Question No. 12:

( Marks: 3 )

(1) An array day is declared as: int day[] = {1, 2, 3, 4, 5, 6, 7};

How many elements does array 'day' has?

7 elements

(2) If the declaration is changed as: int day[7] = {1, 2, 3, 4, 5, 6, 7};

How many elements does array 'day' has?

7 elements

### CS201 Midterm Paper Question No. 13:

( Marks: 5 )

What are similarities and differences between Structures and Unions?

In structures, we have different data members and all of these have their own memory space. In union, the

memory location is same while the first data member is one name for that memory location. However, the

2nd data member is another name for the same location and so on. Consider the above union (i.e.

intOrChar) that contains an integer and a character as data members. What will be the size of this union?

The answer is the very simple. The union will be allocated the memory equal to that of the largest size data

member. If the int occupies four bytes on our system and char occupies one byte, the union intOrChar will

occupy four bytes

### CS201 Midterm Paper Question No. 14:

what is the difference in pointer and veriable?

### CS201 Midterm Paper Question No. 15:

what is the difference in tellg() and tellp()

tellg () gives us the current get position of the file pointer, tellp () function is used to determine the next position to write a character

### CS201 Midterm Paper Question No. 16:

why we close a file after use?

### CS201 Midterm Paper Question No. 17:

call by value and call by reference?

There is another way to call a function in which the function can change the values of variables that are passed as arguments, of

calling program. Such function call is known as call by reference.

Call by value means that when we call a function and pass some parameter to it, the calling function gets the

copy of the value and the original value remains unchanged.

### CS201 Midterm Paper Question No. 18:

give one use of pointer

The one use of pointer is to interchange two values that means it is used to swapped the values.

### CS201 Midterm Paper Question No. 19:

bubble sort

Bubble sorting is a technique, in which we put value of one variable in a temporary location to

preserve it and assign the value of second variable to the first. Then the temporary value is

assigned to the second variable

3. what happened when we increment pointer

The effect of the increment operator ++ on a pointer object is to have the new address to which it

points be the starting location of the object immediately after the object to which it previously

pointed.

### CS201 Midterm Paper Question No. 20:

basic steps for file handling

The basic steps of file handling are:

Open the file