CS201 past paper | past paper | current paper

  

 


 

CS201 past paper | past paper | current paper

Latest Solved Mcqs from Midterm Papers

 

May 07,2011

 

Lectures 1-22

Mc100401285           moaaz.pk@gmail.com               Moaaz Siddiq Bc100400662       bc100400662asad@gmail.com            Asad Ali

 

Latest Mcqs

 

MIDTERM EXAMINATION

Spring 2010

 

 

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

In order to get 256 from the number 2568 we divide this number by 10 and take,

  Its remainder

  The number

  Its quotient

  Its divisor

 

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

The correct syntax of do-while loop is,

  (condition ) while; do { statements; };

  { statements; } do-while ();

  while(condition); do { statements; };

  do { statements; } while (condition);

 

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

Which of the following function(s) is/are included in stdlib.h header file?

 

  double atof(const char *nptr)

  int atoi(const char *nptr)

  char *strcpy ( char *s1, const char *s2)

  1 and 2 only (Pg 191)

 

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 (Pg 76)

  No effect on program

  Program stops its execution


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

The data type before a function name represents its,

  Return Type ( Pg 499)

  Function data

  Function arguments

  Function name

 

 

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

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

  tellptr()

  write()

  seekg()

  get() (Pg 215)

 

 

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

What does 5 | 6 , evaluate to in decimal where ‘|’ is bitwise OR operator?

 

►

►4

►5

►


5 | 6 =

0 1 0 1

0 1 1 0

--------

0 1 1 1 = 7

 

 

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

                                                                                                                                                     C is widely known as development language of                operating system.

  Linux

  Windows

  Unix (Pg 12)

  Mac OS

 

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

                                                                                                                                                     What will be the result of arithmetic expression 6+27/3*3?

  33

  45

  9


  30

 

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

                                                                                                                                                     How many bytes are occupied by declaring following array of characters?

char str[] = “programming”;

 

  10

  11

  12

  13

 

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

                                                                                                                                                     What will be the correct syntax for initialization of pointer ptr with string "programming"?

  char ptr = ’programming’ ;

  char *ptr = “programming” ;

  char *ptr = ‘programming’ ;

  *ptr = “programming” ;

 

pg 166

array element in each array initialized with a single character enclosed in single quote. pg 21

While assigning a character value to a char type variable single quotes are used around the character as ‘a’.

 

 

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

What will be the result of expression x%= 2, if x = 7?

►x = 1

►x = 3

►x = 7

►x = 2

 

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

UNIX has been developed in                  language.

►JAVA

►B

►C (pg 12)

►FORTRAN

 

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

Declaring structures does not mean that memory is allocated.

►True (Pg 229)

►False


http://www.exforsys.com/tutorials/c-plus-plus/c-structures.html

 

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

What will be the value of i and j in the following code segment?

int i, j ;

int x[5] = {2, 3, 4, 8, 9} ;

int *ptr =&x[2]; i = (*ptr)++ ;

j = *ptr++ ;

 

►i = 5, j = 5

►i = 5, j = 8

►i = 4, j = 8

►i = 5, j = 9

 

 

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

When an array element is passed to a function, it is passed by------------- --.

 

 

► reference (Pg 266)

► data type

► value

► data

When we pass ordinary variables to functions, they are passed by value because of the default behavior. But when an array is passed to a function, the default behavior changes and array is passed by reference

 

 

MIDTERM EXAMINATION 2010

 

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

What is the output of the following statement?

int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10);

(a) 510

(b)  5

(c)  48

(d)  error

 

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

What does !(7) evaluate to in decimal where ! is a NOT operator?

(a)  7

(b) 8

(c) 9

(d) 10


 

 

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

The condition in while loop may contain logical expression but not relational expression.

(a)  True

(b)  False

 

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

Searching is easier when an array is already sorted

(a)  True

(b) False

 

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

If an array has 100 elements, what is allowable range of subscripts?

(a) 0 - 99

(b) 1 - 99

(c) 0 - 100

(d) 1 - 100

 

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

What will be the value of ‘a’ and ‘b’ after executing the following statements?

a = 3;

b = a++;

 

(a) 3, 4

(b) 4, 4

(c) 3, 3

(d) 4, 3

 

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

What will be the correct syntax to initialize all elements of two-dimensional array to value 0? (a) int arr[2][3] = {0,0} ;

(b) int arr[2][3] = {{0},{0}} ;

(c) int arr[2][3] = {0},{0} ;

(d) int arr[2][3] = {0} ;

 

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

Which of the following functionreturns the size of a string variable?

 

(a)            strlength()

(b)           stringlen()

(c)           strlen()

(d)           strLength()

 

When applied to a character array, the strlen function returns the length of the string stored there,


not its allocated size. http://www.gnu.org/s/hello/manual/libc/String-Length.html

 

 

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

What will be the range of numbers generated by function rand () % 9?

(a)  0 to 9

(b)  1 to 9

(c)  0 to 8

(d)  1 to 8

 

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

Computer can understand only machine language code.

(c)  True

(d) False

 

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

What does 5 ^ 6 , evaluate to in decimal where ‘^’ is Exclusive OR operator?

(a)  True

(b)   False Detail:- It mean

5 = 0101

6 = 0110

5 ^ 6 = 0011

If both input is same then the output is 0 and if different then output is 1

 

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

If the file is not properly closed in the program, the program                        _.

 

(a)            Terminate normally

(b)           Indicate Runtime error

(c)            Indicate Compile time error

(d)            Crashes

 

Eventually run out of file handles and/or memory space and crash.)

http://www.codingunit.com/c-tutorial-file-io-using-text-files

 

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

Which of the following header file include string conversion functions?

 

(a)          string.h

(b)         stdlib.h (Pg 190)

(c)            ctype.h

(d)           sconvert.h


 

 

 

MIDTERM EXAMINATION 2009

 

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

A precise sequence of steps to solve a problem is called

Ø  Statement

Ø  Program

Ø  Utility

Ø  Routine

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

The Compiler of C language is written in

Ø  Java Language

Ø  UNIX

Ø  FORTRON Language

Ø  C Language

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

Initialization of variable at the time of definition is,

Ø  Must

Ø  Necessary

Ø  Good Programming

Ø  None of the given options

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

In if structure the block of statements is executed only,

Ø  When the condition is false

Ø  When it contain arithmetic operators

Ø  When it contain logical operators

Ø  When the condition is true

 

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

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

Ø  True

Ø  False

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

Pointer is a variable which store,

Ø  Data

Ø  Memory Address

Ø  Data Type

Ø  Values

 

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

Preprocessor program perform its function before               phase takes place.

Ø  Editing


Ø  Linking

Ø  Compiling

Ø  Loading

 

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

Which of the following can not be a variable name?

Ø  area

Ø  _area

Ø  10area

Ø  area2

 

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

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

Ø  for

Ø  while

Ø  do-while

Ø  all looping processes require that the iterations be known

Ø

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

Which character is inserted at the end of string to indicate the end of string?

Ø  new line

Ø  tab

Ø  null

Ø  carriage return

 

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

Which of the following header file defines the rand() function?

Ø  iostream.h

Ø  conio.h

Ø  stdlib.h

Ø  stdio.h

 

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

Commenting the code                                           

Ø  Makes a program easy to understand for others.

Ø  Make programs heavy, i.e. more space is needed for executable.

Ø  Makes it difficult to compile

Ø  All of the given options.

 

Question No: 15 ( 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: 16 ( Marks: 1 ) - Please choose one

For which array, the size of the array should be one more than the number of elements in an array?

Ø  int

Ø  double

Ø  float

Ø  char

 

MIDTERM EXAMINATION 2009

 

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

The function of cin is

  To display message

  To read data from keyboard

  To display output on the screen

  To send data to printer

 

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

In C/C++ language the header file which is used to perform useful task and manipulation of character data is

  cplext.h

  ctype.h (Pg 188)

  stdio.h

  delay.h

 

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

How many parameter(s) function getline() takes?

  0

  1

  2

  3

The member function getline() also takes three parameters: the buffer to fill, one more than the maximum number of characters to get, and the termination character. getline()functions exactly like get() does with these parameters, except getline() throws away the terminating character. http://newdata.box.sk/bx/c/htm/ch16.htm

.

 

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

Word processor is

  Operating system

  Application software

  Device driver


  Utility software

 

 

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

For which values of the integer _value will the following code becomes an infinite loop?

int number=1; while (true) { cout << number;

if (number == 3) break; number += integer_value; }

  any number other than 1 or 2

  only 0

  only 1

  only 2

Rational:

number += integer_value................ above line decide the fate of loop so any thing other then zero leads

to value of 3 which will quite the loop. Only zero is the value which keeps the loop infinite.

 

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

Each pass through a loop is called a/an

  enumeration

  Iteration

  culmination

  pass through

 

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

A continue statement causes execution to skip to

  the return 0; statement

  the first statement after the loop

  the statements following the continue statement

  the next iteration of the loop

Continue statement is used, when at a certain stage, you don’t want to execute the remaining statements inside your loop and want to go to the start of the loop.

 

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

What is the correct syntax to declare an array of size 10 of int data type?

  int [10] name ;

  name[10] int ;

  int name[10] ;

  int name[] ;

 

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

Consider the following code segment. What will the following code segment display?

int main(){

int age[10] = {0}; cout << age ;


}

  Values of all elements of array

  Value of first element of array

  Starting address of array

  Address of last array element

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

How many bytes will the pointer intPtr of type int move in the following statement?

intPtr += 3 ;

  3 bytes

  6 bytes

  12 bytes

  24 bytes

one int is 4 bytes so 4*3 = 12 bytes movement.

 

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

If there are 2(n+1) elements in an array then what would be the number of iterations required to search a number using binary search algorithm?

  n elements

  (n+1) elements

  2(n+1) elements

  2(n+1) elements

 

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

Which of the following operator is used to access the value of variable pointed to by a pointer?

  * operator

  -> operator

  && operator

  & operator

 

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

The                    statement interrupts the flow of control.

  switch

  continue

  goto

  break

 

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

Analysis is the-------------- step in designing a program

  Last

  Middle

  Post Design

  First

Analysis will be always followed by design and then code.

 

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

Paying attention to detail in designing a program is                    

  Time consuming


  Redundant

  Necessary

  Somewhat Good

In programming, the details matter. This is a very important skill. A good programmer always analyzes the problem statement very carefully and in detail. You should pay attention to all the aspects of the problem.

 

MIDTERM EXAMINATION

Spring 2009

 

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

There are mainly------------------ types of software

Two

Three

Four

Five

Software is categorized into two main categories

·         System Software

·         Application Software

 

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

In C/C++ the #include is called,

Header file

Preprocessor Directive (Pg 15)

Statement

Function

 

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

&& is---------------- operator.

An arithmetic

Logical

Relational

Unary

we use logical operators ( && and || ) for AND and OR respectively with relational operators.

 

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

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

Rectangle

Circle

Arrow

Diamond (Pg 51)

http://www.ehow.com/about_5081911_symbols-used-flowchart.html

 

 

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

C++ views each file as a sequential stream of                                  .

Bytes


Bits

0’s or 1’s

Words

 

 

 

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

If the elements of an array are already sorted then the useful search algorithm is,

Linear search

Binary search (Pg 188)

Quick search

Random search

In binary search algorithm, the ‘divide and conquer’ strategy is applied. This plies only to sorted arrays in ascending or descending order.

 

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

The address operator (&) can be used with,

Statement

Expression

Variable

Constant

 

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

When a pointer is incremented, it actually jumps the number of memory addresses

According to data type (Pg 160)

1 byte exactly

1 bit exactly

A pointer variable can not be incremented

 

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

Call by reference mechanism should be used in a program when there is

i.   large amount of data to be passed

ii.   small amount of data to be passed

iii.   need to change the passed data

iv.   no need to change the passed data

Choose the appropriate option for the above case.

  (i) and (ii) only

(i) and (iii) only

(ii) and (iii) only

(ii) and (iv) only

 

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

Which of the following is the starting index of an array in C++?

0

►1

-1

any number


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

The return type of a function that do not return any value must be                     

int

void

double

float

 

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

Which of the following is an extension of header file?

.exe

.txt

.h

.c

 

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

We want to access array in random order which approach is better?

Pointers

Array index (Pg 176)

Both pointers and array index are better

None of the given options.

 

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

When we declare a multidimensional array the compiler store the elements of multidimensional array in the form of,

Columns

Rows

Contiguous memory location (Pg 174)

Matrix

 

 

MIDTERM EXAMINATION 2009

 

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 http://www.lugaru.com/man/String.Constants.html

 

 

 

Question No: 2 ( Marks: 1 ) - Please choose one The size of int data type is


  1 bytes

  2 bytes

  3 bytes

  4 bytes (Pg 257)

 

 

 

Question No: 3 ( Marks: 1 ) - Please choose one In Flow chart process is represented by

  Rectangle (Pg 51)

  Arrow symbol

  Oval

  Circle

 

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 (3*2=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      http://www.allinterview.com/showanswers/65662.html

 

 

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       (Pg 77)

 

 

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: 15 ( Marks: 1 ) - Please choose one

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

 

  True http://mathbits.com/mathbits/compsci/Structures/Define.htm

   False

 

 

Question No: 16 ( Marks: 1 ) - Please choose one Syntax of union is identical to              

  Structure (pg 242)

  Class

  Function

  None of the given options

 

MIDTERM EXAMINATION

2008

 

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

                                                                                                                                                     In Program commenting the code liberally is

  Useful.

  Time consuming

  Not necessary

 

Question :If we want to store a string “abc” in an array str then the size of this array must be at least,

(a)   2

(b)   3

(c)    4

(d)   5

 

Question :How many bytes will the pointer intPtr of type int move in the following statement?

intPtr += 3 ;

 

(a)    3 bytes

(b)   6 bytes

(c)    12 bytes

(d)   24 bytes

MIDTERM EXAMINATION

2007

Question:The remainder (%) operator is,

An arithmetic operator (Pg 258)

A logical operator

A relational operator

A division operator


Question: When a call to function statement is encountered,

The control is transferred to its Prototype

The control is transferred to its definition

The compiler stop execution of the whole program

The program hangs

 

 

MIDTERM EXAMINATION

2006

 

Question : The value of 2*15/3*7+3*2 is

Ø  146

Ø  76

Ø  8

Ø  70

 

Question: Carefully analyze the following lines of code and choose 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 :The size of a double variable is

Ø  2 bytes

Ø  4 bytes

Ø  8 bytes

Ø  10 bytes

The size of an int is:          4 bytes. The size of a short int is:             2 bytes. The size of a long int is:       4 bytes. The size of a char is:                  1 bytes. The size of a float is:                 4 bytes. The size of a double is:                8 bytes.

 

 

Previous Post Next Post

Blog ads

Nepali Graphics - Learn design, Animation, and Progrmming