cs201 Lecture no 3.pdf

Verified academic study resource for CS201 (Introduction to Programming) under the Computer Science at Virtual University of Pakistan. This PDF document (Official Lecture Handouts & Highlighted Notes) covers Complete Course Handouts (Lectures 1 to 45) spanning approximately 450 pages across 8 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
Handout
Coverage
Complete Course Handouts (Lectures 1 to 45)
Tags
LECTURE

Virtual University examiners construct 100% of objective MCQs and subjective marking schemes directly from the official CS201 handouts.

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)
  5. Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
  6. Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
  7. Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
  8. Final-Term Examination Dossier & Capstone Synthesis — Lectures 42 to 45 (Pages 511 to 585). Final-Term Exam Synthesis (Lectures 23–45 Scope)

Frequently asked questions

Where can I download cs201 Lecture no 3.pdf for free?

You can preview and download "cs201 Lecture no 3.pdf" (CS201 PDF, ~450 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs201-lecture-no-3-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 Complete Course Handouts (Lectures 1 to 45) across 8 distinct lecture units (Lectures 1 to 6, Lectures 7 to 12, Lectures 13 to 18, Lectures 19 to 22, Lectures 23 to 29, Lectures 30 to 36, Lectures 37 to 41, Lectures 42 to 45), 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

Lecture No. 3

Reading Material

Deitel & Deitel – C++ How to Program                                  chapter 1
                                                                      1.19, 1.20, 1.21,
1.22

Summary

First C program
Variables
Data Types
Arithmetic Operators
Precedence of Operators
Tips

First C program

The best way to learn C is to start coding right away. So here is our very first program
in C.
Right programm.
#include <iostream>
Using namespace std;
Int main()
{
Cout <<”virtual university of pakistan”;
Return 0;
}
#include: This is a
pre-processor directive. It is not part of our program; it is an instruction to the
compiler. It tells the C compiler to include the contents of a file, in this case the
system file iostream.h. The compiler knows that it is a system file, and therefore
looks for it in a special place. The features of preprocessor will be discussed later. For
the time being take this line on faith. You have to write this line. The sign # is known
as HASH and also called SHARP.

<iostream.h>
This is the name of the library definition file for all Input Output Streams. Your
program will almost certainly want to send stuff to the screen and read things from the
keyboard. iostream.h is the name of the file in which has code to do that work for
you

main()
The name main is special, in that the main is actually the one which is run when your
program is used. A C program is made up of a large number of functions. Each of
these is given a name by the programmer and they refer to each other as the program
runs. C regards the name "main" as a special case and will run this function first. If
you forget to have a main function, or mistype the name, the compiler will give you
an error.

Notice that there are parentheses (“( )”, normal brackets) with main. Here the
parentheses contain nothing. There may be something written inside the parentheses.
It will be discussed in next lectures.
{}
Next, there is a curly bracket also called braces("{ }"). For every open brace there
must be a matching close. Braces allows to group together pieces of a program. The
body of main is enclosed in braces. Braces are very important in C; they enclose the
blocks of the program.
cout << “ Welcome to Virtual University of Pakistan”
cin>>”
cout:
This is known as out put stream in C and C++. Stream is a complicated thing, you will
learn about it later. Think a stream as a door. The data is transferred through stream,
cout takes data from computer and sends it to the output. For the moment it is a
screen of the monitor. hence we use cout for output.
<<
The sign << indicates the direction of data.{insertion operators }{>>Extraction} Here it is towards cout and
the function of
cout is to show data on the screen.
“ Welcome to Virtual University of Pakistan”
The thing between the double quotes (“ ”) is known as character string. In C
programming character strings are written in double quotes. Whatever is written after
<< and within quotation marks will be direct it to cout, cout will display it on the
screen.
;
There is a semicolon (;) at the end of the above statement. This is very important. All
C statements end with semicolon (;). Missing of a semicolon (;) at the end of
statement is a syntax error and compiler will report an error during compilation. If
there is only a semicolon (;) on a line than it will be called a null statement. i.e. it does
nothing. The extra semicolons may be put at the end but are useless and aimless. Do
not put semicolon (;) at a wrong place, it may cause a problem during the execution of
the program or may cause a logical error.
In this program we give a fixed character string to cout and the program prints it to
the screen as:
variable
During programming we need to store data. This data is stored in variables. Variables
are locations in memory for storing data. The memory is divided into blocks. It can be
viewed as pigeon-holes. You can also think of it as PO Boxes. In post offices there are
different boxes and each has an address. Similarly in memory, there is a numerical
address for each location of memory (block). It is difficult for us to handle these
numerical addresses in our programs. So we give a name to these locations. These

names are variables. We call them variables because they can contain different values
at different times.

The variable names in C may be started with a character or an underscore ( _ ). But
avoid starting a name with underscore ( _ ). C has many libraries which contain
variables and function names normally starting with underscore ( _ ). So your variable
name starting with underscore ( _ ) may conflict with these variables or function
names.
In a program every variable has
Name
Type
Size
Value
The variables having a name, type and size (type and size will be discussed later) are
just empty boxes . They are useless until we put some value in them. To put some
value in these boxes is known as assigning values to variables. In C language, we use
assignment operator for this purpose.
Assignment Operator
In C language equal-to-sign (=) is used as assignment operator. Do not confuse the
algebraic equal-to with the assignment operator. In Algebra X = 2 means the value of
X is 2, whereas in C language X = 2 (where X is a variable name) means take the
value 2 and put it in the memory location labeled as X, afterwards you can assign
some other value to X, for example you can write X = 10, that means now the
memory location X contains the value 10 and the previous value 2 is no more there.
Assignment operator is a binary operator (a binary operator has two operands). It must
have variable on left hand side and expression (that evaluates to a single value) on
right hand side. This operator takes the value on right hand side and stores it to the
location labeled as the variable on left hand side, e.g. X = 5, X = 10 + 5, and X = X
+1.
In C language the statement X = X + 1 means that add 1 to the value of X and then
store the result in X variable. If the value of X is 10 then after the execution of

More CS201 files

All CS201 files · Midterm Prep 2026 · MCQs Bank