CS201-midterm subjectives solved with references by moaaz.pdf

Verified academic study resource for CS201 (Introduction to Programming) under the Computer Science at Virtual University of Pakistan. This PDF document (Midterm Solved Past Paper & Revision File compiled by Moaaz Siddhu) covers Mid-Term Exam Scope (Lectures 1 to 22) spanning approximately 240 pages across 4 curriculum modules, and is indexed for student examination review with instant in-browser preview and 100% free direct download.

Course
CS201 – Introduction to Programming
Faculty
Computer Science
Format
PDF
Type
Midterm
Coverage
Mid-Term Exam Scope (Lectures 1 to 22)
Compiled by
Moaaz Siddhu
Tags
SUBJECTIVE, SOLVED, MIDTERM

Focus on core definitions and repeated MCQs from Lectures 1–22. Remember that scoring in the First Half builds your safety buffer toward the mandatory 20% Two-Half passing rule in CS201.

What this file covers — CS201 syllabus roadmap

  1. Core Architecture, Syntax & Primitive Data Structures — Lectures 1 to 6 (Pages 1 to 65). 15% Objective Marks (8–10 MCQs)
  2. Conditional Branching, Loops & Logical Control Flow — Lectures 7 to 12 (Pages 66 to 140). 18% Exam Marks (MCQs + 2-Mark Short Questions)
  3. Memory Management, Pointers, Arrays & Functions — Lectures 13 to 18 (Pages 141 to 215). 22% Exam Marks (High Yield for Midterms)
  4. Midterm Consolidation, Strings & Algorithm Synthesis — Lectures 19 to 22 (Pages 216 to 280). Midterm Exam Culmination (Lectures 1–22 Scope)

Frequently asked questions

Where can I download CS201-midterm subjectives solved with references by moaaz.pdf for free?

You can preview and download "CS201-midterm subjectives solved with references by moaaz.pdf" (CS201 PDF, ~240 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs201-midterm-subjectives-solved-with-references-by-moaaz-pdf) with 100% free high-speed downloads and zero registration requirements.

What syllabus chapters and lectures are covered in this CS201 file?

This document covers Mid-Term Exam Scope (Lectures 1 to 22) across 4 distinct lecture units (Lectures 1 to 6, Lectures 7 to 12, Lectures 13 to 18, Lectures 19 to 22), featuring comprehensive definitions, solved objective questions, and examiner marking rubrics.

What is the passing criteria for CS201 under the VU 20% Two-Half Rule?

Under official Virtual University regulations, students must score at least 20% in the First Half (Quizzes, Assignments, GDBs, and Midterm combined) AND independently at least 20% in the Final-Term examination paper. Scoring under 20% in the final exam results in an automatic F grade regardless of earlier marks.

Are CS201 solved past papers and handouts verified for 2026 exams?

Yes. All CS201 materials on MIHORA VU—including Moaaz, Waqar Siddhu, and team archives—are reviewed against the current VU syllabus to help students prepare for 2026 Midterm, Final-Term, and online quiz examinations.

Inside this file

                              CS201-introduction to programing
                          Latest Solved subjective from Midterm Papers                                               May 10,2011

Lectures 1-22 Mc100401285                        moaaz.pk@gmail.com                         Moaaz Siddiq           Latest subjectives

                                              MIDTERM EXAMINATION
                                                    Spring 2010
Question No: 17 ( Marks: 2 )
What is the difference between switch statement and if statement.
Answer:
   1.if statement is used when we have to check two conditions while switch is a multi conditional control statement

   2. SWITCH statement can be executed with all cases if the “break” statement is not used whereas IF statement has to be true
   to be executed further.

Question No: 18 ( Marks: 2 )
Why we close a file after use?
Answer:
To save our data stored on file. Also this process makes our program fast and reliable.
                         OR
You have finished with it. This is particularly important if you are writing to the file. The operating system does not switch on the
disk drive to write just a single character to the disk, rather it waits until it has a load to write and then writes the lots in one go.
http://www2.sis.pitt.edu/~ir/KS/Data/RMiles/c12.html

Question No: 19 ( Marks: 2 )
A two-dimensional array has 3 rows and 4 columns. Write down the syntax to initialize first element of all
three rows of two-dimensional array with value 2.
Answer:
 int matrix[0][0]=2
 int matrix[1][0]=2
 int matrix[2][0]=2

Question No: 20 ( Marks: 3 )
Identify the errors in the following code segment and give the reason of errors.
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}

Answer:
 Int x=10….No ending semicolon.
*ptr=5... Declaring a pointer to constant integer. You cannot use this pointer to change the value being
pointed to.

Question No: 21 ( Marks: 3 )
Can you use an assignment operator to assign the value of one C-string to another?

Answer:
Yes we can assign the one value of C-string to another using assignment operator. We can
assign the value of one string to another string through this method.
A[0]=B[0]
A[1]=B[2]
A[3]=B[3]
And we can assign the whole string to another C string using Assignment operator by using loops.

Question No: 22 ( Marks: 5 )
Why binary search algorithm is more efficient than the linear search algorithm?
Answer: (page118)
Binary search algorithm is more efficient than liner algorithm because the arrays are sorted in asending or
desending order and we use “devide and conqrer” technique. In binary search each iteration reduces the
search by the factor of two but in the linear we have the same number of searches as we have the number of
elements.e.g,if we have array of 1000 elements the linear search will take 1000 iterations however binary
search will take max 10.

Question No: 23 ( Marks: 5 )
Write down the output of the code given below :
Hint:
Size of char is 1 byte
Size of int is 2 byte
Size of float is 4 byte

#include <iostream.h>

union mytypes_t {
 char c;
 int i;
 float f;
 } mytypes;

int main(){

  mytypes.c = 'H';
  mytypes.i = 15;

  cout << sizeof(mytypes)<<endl;

    mytypes.i = 15;
    mytypes.c = 'H';

    cout << sizeof(mytypes)<<endl;

    system("PAUSE");
    return 0;
}

Question No: 16 ( Marks: 1 ) - Please choose one
In Program commenting the code liberally is
 Answer: (page 06)
It need to be self-contained and understandable. Comments should be placed liberally. The comments
should explain the logic, not the mechanics. Try to avoid fancy programming.

Question No: 17 ( Marks: 1 )
Which header file must be included while handling files?
Answer: (page 199)
Include <fstream.h>

Question No: 18 ( Marks: 1 )
What is meant by C++ statement: const int *ptr = &x;
Answer:
ptr is a pointer to data of type const int type. And to assign the address of x to pointer ptr

Question No: 19 ( Marks: 2 )
What is a truth Table?
Answer: (page 562)
We know the concept of truth table. The truth tables are very important. These are still a tool available for
analyzing logical expressions. We will read logic design in future, which is actually to do with chips and
gate. We find it difficult to evaluate a complicated logical expression. Sometimes the logic becomes
extremely complicated so that even writing it as a simple syntax statement in any language. These are used to
make a big circuit with the use of minimum chips. These minimization techniques deal with Boolean algebra i.e.
logic.

Question No: 20 ( Marks: 3 )
(1) An array day is declared as: int day[] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?
Answer:
7 elements

(2) If the declaration is changed as: int day[7] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?
Answer:
7 elements

Question No: 21 ( Marks: 5 )
What are similarities and differences between Structures and Unions?
Answer: (page 242)
In structures, we have different data members and all of these have their own memory space. In union, the
memory location is same while the first data member is one name for that memory location. However, the
2nd data member is another name for the same location and so on. Consider the above union (i.e.
intOrChar) that contains an integer and a character as data members. What will be the size of this union?
The answer is the very simple. The union will be allocated the memory equal to that of the largest size data
member. If the int occupies four bytes on our system and char occupies one byte, the union intOrChar will
occupy four bytes

Question: 1-difference in pointer and veriable?
Question: 2-differenc in tellg() and tellp()
Answer: 215
tellg () gives us the current get position of the file pointer, tellp () function is used to determine the next position to write a character

Question: 3-why we close a file after use? repeat

Question: call by value and call by reference?
Answer: 84-266
There is another way to call a function in which the function can change the values of variables that are passed as arguments, of

More CS201 files

All CS201 files · Midterm Prep 2026 · MCQs Bank