Advertisement

cs201 fall 2009 latest paper

Midterm of cs201 latest

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

In C/C++ the string constant is enclosed

► In curly braces

► In small braces

► In single quotes

► In double quotes

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

The size of int data type is

► 1 bytes

► 2 bytes

► 3 bytes

► 4 bytes

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

In Flow chart process is represented by

► Rectangle

► Arrow symbol

► Oval

► Circle

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

If the break statement is missed in switch statement then,

► The compiler will give error

► This may cause a logical error

► No effect on program

► Program stops its execution

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

When we are using const keyword with a variable x then initializing it at the time of declaration is,

► Must

► Optional

► Not necessary

► A syntax error

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

Which of the following is the correct way to assign an integer value 5 to element of a matrix say ‘m’ at second row and third column?

m[2][3] = 5 ;

m[3][2] = 5 ;

m[1][2] = 5 ;

m[2][3] = ‘5’;

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

How many total elements must be in two-dimensional array of 3 rows and 2 columns?

► 4

► 5

► 6

► 7

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

Which of the following is the correct statement for the following declaration?

const int *ptr.

ptr is a constant pointer

►ptr is constant integer pointer

►ptr is a constant pointer to int

►ptr is a pointer to const int

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

Consider the following code segment. What will be the output of this code segment?

int arr[6] = {2, 3, 7, 4, 5, 6} ;

int *ptr1 =&arr[1] ;

int *ptr2 = &arr[4] ;

cout << (ptr2-ptr1) ;

► 3

► 9

► 12

► 2

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

What will be the correct syntax to assign an array named arr of 5 elements to a pointer ptr?

*ptr = arr ;

►ptr = arr ;

►*ptr = arr[5] ;

►ptr = arr[5] ;

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

C is a/an ______ language

►low level

►object based

►object oriented

►function oriented

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

►.exe

►.txt

►.h

►.c

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

The variables having a name, type and size are just like empty boxes.

►False

►True

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

What's wrong with this for loop?

for (int k = 2, k <=12, k++)

► the increment should always be ++k

► the variable must always be the letter i when using a for loop

► there should be a semicolon at the end of the statement

► the commas should be semicolons

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

Most efficient method of dealing with structure variables is to define the structure globally

True

►False

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

Syntax of union is identical to ______

Structure

Class

Function

None of the given options

Question No: 17 ( Marks: 1 )

Suppose ‘z’ is a variable of type int. What will be the result of x = 27/4:

Question No: 18 ( Marks: 1 )

Give the general syntax of definition of structure.

Question No: 19 ( Marks: 2 )

Consider the structure

struct Customer

{

int custnum;

int salary;

float commission;

};

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: 20 ( Marks: 3 )

What is compiler?

Question No: 21 ( Marks: 5 )

What is the difference between while and for loop?

Question No: 22 ( Marks: 10 )

Write a void function( ); that takes integer numbers from the user and then displays the sum of odd and even numbers entered by the user. Your program should terminate if user enters a negative number

0 Responses