CS201 - Midterm Solved Mcqs With References by Moaaz and Asad
CS201 - Midterm Solved Mcqs With References by Moaaz and Asad
MIDTERM EXAMINATION
►3
►4
►5
►7
5|6=
0101
0110
--------
0111=7
► 10
► 11
► 12
► 13
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’.
►i = 5, j = 5
►i = 5, j = 8
►i = 4, j = 8
►i = 5, j = 9
MIDTERM EXAMINATION
(a) 3, 4
(b) 4, 4
(c) 3, 3
(d) 4, 3
(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,
Eventually run out of file handles and/or memory space and crash.)
http://www.codingunit.com/c-tutorial-file-io-using-text-files
(a) string.h
(b) stdlib.h (Pg 190)
(c) ctype.h
(d) sconvert.h
MIDTERM EXAMINATION
MIDTERM EXAMINATION
MIDTERM EXAMINATION
Which of the following is the correct statement for the following declaration?
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
► True http://mathbits.com/mathbits/compsci/Structures/Define.htm
► False
MIDTERM EXAMINATION
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
MIDTERM EXAMINATION
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