0% found this document useful (0 votes)
6 views

cs201-midterm-solved-mcqs-with-reference

The document is a midterm solved paper for a CS201 course, containing multiple-choice and short-answer questions related to programming concepts. Topics include output evaluation, logical and relational expressions, array initialization, string functions, and file handling. It also includes questions on truth tables, structures vs unions, and a programming task involving user input and conditional termination.

Uploaded by

Muhammad Waqas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

cs201-midterm-solved-mcqs-with-reference

The document is a midterm solved paper for a CS201 course, containing multiple-choice and short-answer questions related to programming concepts. Topics include output evaluation, logical and relational expressions, array initialization, string functions, and file handling. It also includes questions on truth tables, structures vs unions, and a programming task involving user input and conditional termination.

Uploaded by

Muhammad Waqas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS201 - Midterm Solved Paper

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()
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
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
Question No: 15 ( Marks: 1 ) - Please choose one
Which of the following header file include string conversion functions?
(a) string.h
(b) stdlib.h
(c) ctype.h
(d) sconvert.h
Question No: 17
(M-1)
Which header file must be included while handling files?

Question No: 18
(M-1)
What is meant by C++ statement: const int *ptr = &x;

Question No: 19
(M-2)
What is a truth Table?

Question No: 20 ( M - 3 )
(i) An array day is declared as: int day[] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?
(ii) If the declaration is changed as: int day[7] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?

Question No: 21 ( M - 5 )
What are similarities and differences between Structures and Unions?

Question No: 22 ( M - 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?

You might also like