CS201 | MID Term |mcq
by moaaz and asad with reference
CS201 MID TERM A
DIRECTION TO PASS INTRODUCTION TO
PROGRAMMING
CS201
MIDTERM MCQS MEGA FILE |
Question
Which of the following can not be a variable name?
Ø area
Ø _area
Ø 10area
Ø area2
Question
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 Which character is inserted at the end of string to
indicate the end of string?
Ø new line
Ø tab
Ø null
Ø carriage return
Question
Which of the following header file defines the rand() function?
Ø iostream.h
Ø conio.h
Ø stdlib.h
Ø stdio.h
Question
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
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
For which array, the size of the array should be one more than the
number of elements in an array?
Ø int
Ø double
Ø float
Ø char
Question
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
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
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.
.
Question
Word processor is
► Operating system
► Application software
► Device
driver
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
Each pass through a loop is called a/an
► enumeration
► Iteration
► culmination
► pass through
Question
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
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
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
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
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
Which of the following operator is used to access the value of
variable pointed to by a pointer?
► * operator
► -> operator
► && operator
► & operator
Question
The ________ statement interrupts the flow of control.
► switch
► continue
► goto
► break
Question
Analysis is the -------------- step in designing a program
► Last
► Middle
► Post Design
► First
Analysis will be always followed by design and then code.
Question
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.
Question
There are mainly------------------- types of software
►Two
►Three
►Four
►Five
Software is categorized into two main categories
• System Software
• Application Software
Question
In C/C++ the #include is called,
►Header file
►Preprocessor Directive (Pg 15)
►Statement
►Function
Question
&& is------------------ operator.
►An arithmetic
►Logical
►Relational
►Unary
we use logical operators ( && and || ) for AND and OR
respectively with relational operators.
Question
In flow chart, the symbol used for decision making is,
►Rectangle
►Circle
►Arrow
►Diamond (Pg 51)
Question
C++ views each file as a sequential stream of________________
►Bytes
►Bits
►0’s or 1’s
►Words
Question
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.
0 Comments
Post a Comment