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 |
The address
operator (&) can be used with,
►Statement
►Expression
►Variable
►Constant
Question
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
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
► (i) and (ii) only
►(i) and (iii) only
►(ii) and (iii) only
►(ii) and (iv) only
Question
Which of the following is the starting index of an array in C++?
►0
►1
►-1
►any number
Question
The return type of a function that do not return any value must be
__________
►int
►void
►double
►float
Question
Which of the following is an extension of header file?
►.exe
►.txt
►.h
►.c
Question
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
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
Question
In C/C++ the string constant is enclosed
► In curly braces
► In small braces
► In single quotes
► In double quotes
Question
The size of int data type is
1 bytes
► 2 bytes
► 3 bytes
► 4 bytes (Pg 257)
Question
In Flow chart process is represented by
► Rectangle (Pg 51)
► Arrow symbol
► Oval
► Circle
Question
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
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
How many total elements must be in two-dimensional array of 3 rows
and 2 columns?
► 4
► 5
► 6 (3*2=6)
► 7
Question
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
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
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
C is a/an ______ language
►low level
►object based
► object oriented
►function oriented (Pg 77)
Question
The variables having a name, type and size are just like empty
boxes.
► False
► True
Question
Most efficient method of dealing with structure variables is to
define the structure globally
► True
► False
Question
Syntax of union is identical to ______
► Structure (pg 242)
► Class
► Function
► None of the given options
Question
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
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 transfer to its Prototype
►The control is transfer to its definition
►The compiler stop execution of whole program
►The program hangs
Question :
The value of 2*15/3*7+3*2 is
Ø 146
Ø 76
Ø 8
Ø 70
Question:
Carefully analyze the following lines of code and chose 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.
Question :
An array is also called
Ø an array variable
Ø array declaration
Ø struct
Ø constant pointer
0 Comments
Post a Comment