Nexus Learn

Lecture 1: Introduction

Lecture Notes CS-307 Programming Fundamentals 9 min read Updated 8 Nov 2026

↓ Download notes (Word)

On this page
  1. Learning Outcomes
  2. 1. Why Learn Programming?
  3. 2. What Is a Computer?
  4. 3. What Is Programming?
  5. 4. Problem Solving: Algorithms, Pseudocode and Flowcharts
  6. 5. Your First C++ Program
  7. 6. Word Bank (Key Terms)
  8. 7. Self-Check Questions

UNIVERSITY OF AGRICULTURE, FAISALABAD

Department of Computer Science

LECTURE 1 · STUDENT NOTES

Introduction to Computers, Programming & Problem Solving

CS-307 Programming Fundamentals · BSCS Semester 1

Week

Slides

Linked practical

Reference ID

1

Lecture1_Introduction.pptx

Practical 1

N01

Learning Outcomes

SLO

By the end of this lecture you can…

Builds CLO

Bloom level

SLO 1.1

Explain what a computer and a program are

CLO1: Identify the necessary properties of good problem-solving techniques.

C2

SLO 1.2

Tell high-level from low-level languages, and a compiler from an interpreter

CLO4: Describe the syntax and semantics of the C++ programming language.

C2

SLO 1.3

Write a simple algorithm, pseudocode and flowchart

CLO1: Identify the necessary properties of good problem-solving techniques.

C3

SLO 1.4

Understand every line of a "Hello World" C++ program

CLO4: Describe the syntax and semantics of the C++ programming language.

C2

How to use these notes

Read these notes after the lecture and before the practical. Section numbers (for example §3.2) are used in the question bank, so you can always find where an answer comes from. Type every code example yourself — do not copy-paste.

1. Why Learn Programming?

Think about the apps you used today: WhatsApp, YouTube, JazzCash, Daraz. Each one is a program that a person wrote. In this course you will learn to write programs yourself, starting from zero. You do not need any past experience. You only need to practise every day.

Rule #1 of this course

Practise daily. Type the code yourself. You cannot learn swimming by watching videos, and you cannot learn programming by only reading slides.

2. What Is a Computer?

A computer is an electronic machine that takes input, processes it by following instructions, and gives output. It can also store data for later use. (Slides L01-S05 to S07)

2.1 The IPO model (Input → Process → Output)

Part

Meaning

Devices

WhatsApp example

Input

Data going into the computer

Keyboard, mouse, touch screen, microphone

You type a message

Process

The CPU works on the data by following instructions

CPU (Central Processing Unit)

The phone prepares and sends the message

Output

Result shown to the user

Monitor, printer, speaker

The message appears on the screen

Storage

Keeping data for later

RAM (temporary), hard disk/SSD (permanent)

The chat is saved on the phone

RAM (Random Access Memory) is fast but temporary: its data is lost when power goes off. A disk is slower but permanent.

2.2 Hardware and software

Hardware

Software

Meaning

Physical parts you can touch

Instructions (programs) you cannot touch

Examples

CPU, RAM, hard disk, keyboard, monitor

Windows, Android, Chrome, WhatsApp, games

Analogy

The body

The mind

Neither is useful alone. A phone with no software is just a box; software with no hardware has nowhere to run.

2.3 A computer is fast, but not intelligent

A computer does exactly what it is told. If you give it a wrong instruction, it does the wrong thing — very quickly. This is why a programmer must be precise. Is a calculator a computer? Yes: it has input (buttons), process (chip) and output (display). Is a mobile phone a computer? Yes, for the same reason.

3. What Is Programming?

3.1 Program and programming

A program is a set of instructions, written in a language the computer can follow, to do a task. Programming is the process of writing those instructions. (Slide L01-S08)

Cooking

Computing

Recipe

Program

Cook

Computer

Ingredients

Data (input)

Dish

Output

A recipe must be clear and in the right order. If it says "bake" before "mix", the cake fails. A program is the same.

3.2 Levels of programming languages

A computer only understands binary — 0s and 1s. (Slide L01-S09)

Level

Example

Who understands it easily?

Machine language (low-level)

10110000 01100001

Only the computer

Assembly language (low-level)

MOV AL, 61h

Hard for humans; uses short codes

High-level language

cout << "Hello";

Humans — close to English (C++, Python, Java)

3.3 Translators: compiler and interpreter

High-level code must be translated into machine code before the computer can run it. Two kinds of translator do this: (Slide L01-S10)

Compiler

Interpreter

How it works

Translates the whole program at once, then runs it

Translates and runs one line at a time

Languages

C, C++

Python

Real-world example

Translating a whole book before publishing it

A live translator at a conference

Errors

All syntax errors are reported before the program runs

Stops at the first line with an error

C++ uses a compiler, so in this course we compile our programs.

3.4 How a C++ program runs: Write → Compile → Link → Run

(Slide L01-S11)

Step

What happens

File produced

1. Write (edit)

You type the source code in an IDE and save it

hello.cpp (source code)

2. Compile

The compiler checks the grammar (syntax) and translates the code to machine code

hello.o / hello.obj (object code)

3. Link

The linker joins your object code with ready-made library code (for example, the code behind cout)

hello.exe (executable)

4. Run

The operating system loads the .exe into memory and the CPU executes it

Output on screen

Errors are normal

If the compiler finds a mistake, it shows an error. You fix the code and compile again. Every programmer — even an expert — goes around this cycle many times a day.

4. Problem Solving: Algorithms, Pseudocode and Flowcharts

Programming is about 70% thinking and 30% typing. Before writing code, we plan the solution.

4.1 Algorithm and its properties

An algorithm is a finite, step-by-step set of clear instructions to solve a problem. (Slide L01-S12)

Property

Simple meaning

What goes wrong without it

Clear (unambiguous)

Each step has only one meaning

"Add some sugar" — how much?

Finite

It must stop after a limited number of steps

A recipe that says "keep stirring" forever

Input and output

It takes data in and gives a result

No result means the problem is not solved

Effective (doable)

Every step can actually be done

"Find the biggest number that exists" is impossible

Correct order (sequence)

Steps are in the right order

Pouring tea before boiling water

Example – making chai: Start → Boil water → Add tea leaves → Add milk and sugar → Boil for 2 minutes → Pour into cup → End. If we swap step 3 and step 6, the chai is ruined. Order matters.

4.2 Pseudocode

Pseudocode ("pseudo" means not real) is structured, code-like English. It has no strict rules, but it looks close to a real program. (Slide L01-S13)

Algorithm (plain steps)

Pseudocode

1. Start

2. Input number A

3. Input number B

4. Sum = A + B

5. Display Sum

6. End

START

READ A

READ B

SUM ← A + B

PRINT SUM

END

4.3 Flowchart symbols

A flowchart is a picture of an algorithm. (Slide L01-S14) Learn these five symbols by heart:

Symbol

Shape

Used for

Example

Terminal

Oval (rounded)

Start and End

Start

Input / Output

Parallelogram (slanted box)

Reading input or printing output

Read A, B

Process

Rectangle

A calculation or action

Sum = A + B

Decision

Diamond

A yes/no question

A > B ?

Flow line

Arrow

Shows the direction of flow

→

4.4 Worked example: largest of two numbers

(Slide L01-S15) Here we meet a decision for the first time.

Pseudocode

START

READ A, B

IF A > B

PRINT A

ELSE

PRINT B

END

Flowchart: Start (oval) → Read A, B (parallelogram) → A > B ? (diamond) → Yes: Print A / No: Print B (parallelograms) → End (oval).

Dry run (trace with values): A = 7, B = 3 → 7 > 3 is Yes → prints 7. A = 2, B = 9 → 2 > 9 is No → prints 9.

Try it yourself – Pass or Fail (Slide L01-S16)

Input a student's marks. Print PASS if marks ≥ 50, otherwise print FAIL. Write the algorithm, then draw the flowchart.

Check: did you use a diamond for the decision and ovals for Start/End?

5. Your First C++ Program

5.1 Hello World

(Slide L01-S17)

hello.cpp

#include <iostream>

using namespace std;

int main() {

cout << "Hello, World!" << endl;

return 0;

}

Output

Hello, World!

5.2 Line by line

(Slide L01-S18)

Code

Meaning in simple words

#include <iostream>

Brings in the input/output library so we can use cin and cout. Like borrowing a tool box before starting work.

using namespace std;

Lets us write cout instead of the longer std::cout.

int main()

The entry point: every C++ program starts running here.

{ }

Mark the start and end of main's body.

cout << "...";

Prints text to the screen. Say it "see-out" (console output).

endl

"End line" — moves the cursor to a new line.

;

Ends a statement, like a full stop ends a sentence.

return 0;

Tells the operating system the program finished successfully.

5.3 Common beginner errors

(Slide L01-S19)

Mistake

Wrong code

Why it fails

Missing semicolon

cout << "Hi"

Statement not ended; the compiler often reports the next line

Wrong case

Cout << "Hi";

C++ is case-sensitive: Cout ≠ cout

Missing quotes

cout << Hi;

Text must be inside double quotes " "

Missing brace

int main() { ...

Every { needs a matching }

5.4 Tools to get started

  • Dev-C++ – a light IDE for Windows; runs well on lab PCs.
  • Code::Blocks – a free IDE for Windows and Linux (install the version that includes MinGW).
  • Online compilers – OnlineGDB or Programiz work on any phone or browser.
  • An IDE (Integrated Development Environment) is one program where you type, compile and run code — like a kitchen with the stove, knife and plates in one place.

6. Word Bank (Key Terms)

Word

Simple meaning

Algorithm

A clear, finite list of steps to solve a problem

Binary

A number system with only two digits, 0 and 1

Compiler

A translator that converts the whole program into machine code before running

CPU

Central Processing Unit — the "brain" that carries out instructions

Executable (.exe)

The final machine-code file that the computer can run

Flowchart

A diagram of an algorithm made of standard shapes and arrows

Interpreter

A translator that converts and runs one line at a time

Linker

A tool that joins your compiled code with library code to make an executable

Pseudocode

Code-like English used to plan a program

Syntax

The grammar rules of a programming language

Source code

The program text that you type (.cpp file)

7. Self-Check Questions

1. Name the three parts of the IPO model and give one device for each.

2. What is the difference between a compiler and an interpreter?

3. Which flowchart shape is used for a decision?

4. Where does every C++ program start executing?

5. List four properties of a good algorithm.

6. Write an algorithm and draw a flowchart to find the area of a rectangle.

7. Write an algorithm and draw a flowchart to find the largest of THREE numbers.

Answers to 1–5 are in §2.1, §3.3, §4.3, §5.2 and §4.1. Questions 6–7 are your homework (Slide L01-S22).

← All CS-307 material