Slide 2
Today's Plan
90 minutes · 6 modules
Welcome & Course Orientation
10 min
What Is a Computer?
15 min
What Is Programming?
15 min
Problem Solving: Algorithms, Pseudocode, Flowcharts
25 min
Your First C++ Program
20 min
Wrap-up & Homework
5 min
Slide 3
Learning Outcomes (SLOs)
By the end of this lecture, you will be able to: (tag = course outcome it builds · Bloom level)
Explain what a computer and a program are
SLO 1.1 → CLO1 · C2
Tell high-level from low-level languages, and a compiler from an interpreter
SLO 1.2 → CLO4 · C2
SLO 1.3 → CLO1 · C3
SLO 1.4 → CLO4 · C2
Write a simple algorithm, pseudocode and flowchart
Understand every line of a "Hello World" C++ program
- CLO1 Identify the necessary properties of good problem-solving techniques.
- CLO4 Describe the syntax and semantics of the C++ programming language.
Slide 4
Course Roadmap
What we will cover this semester
Unit 1
Unit 2
Unit 3
Unit 4
Computers, algorithms & flowcharts
Variables, data types, I/O, operators
Decisions: if / else, switch
Loops: for, while, do-while
Unit 5
Unit 6
Unit 7
Rule #1
Functions
Arrays & strings
Pointers & structures
Practise daily. Type the code yourself.
"You can't learn swimming by watching videos."
Module 0 · Orientation
Programming Fundamentals · Lecture 1
Slide 5
What Is a Computer?
An electronic machine that takes input, processes it by instructions, and produces output
INPUT
PROCESS
OUTPUT
Keyboard, mouse, touch
CPU follows instructions
Monitor, printer, speaker
STORAGE
RAM (temporary) · Disk (permanent)
Module 1 · What Is a Computer?
Programming Fundamentals · Lecture 1
Slide 6
Hardware vs Software
Hardware
Software
Physical parts you can touch
Instructions you cannot touch
- CPU, RAM, hard disk
- Keyboard, mouse, monitor
- Windows, Android
- Chrome, WhatsApp, games
Analogy: The body
Analogy: The mind
Module 1 · What Is a Computer?
Programming Fundamentals · Lecture 1
Slide 7
KEY IDEA
- A computer is fast,
- but not intelligent.
It does exactly what it is told. Give it a wrong instruction, and it does the wrong thing — very quickly.
Ask the class: Is a calculator a computer? Is your mobile phone a computer?
Slide 8
What Is Programming?
- Program: a set of instructions, in a language the computer can follow, to perform a task.
- Programming: the process of writing those instructions.
Analogy: A program is a recipe
Recipe
Cook
Ingredients
Dish
↓
↓
↓
↓
Program
Computer
Data
Output
Module 2 · What Is Programming?
Programming Fundamentals · Lecture 1
Slide 9
Levels of Programming Languages
Computers only understand binary (0s and 1s)
Machine language
Only the computer understands
10110000 01100001
Assembly language
MOV AL, 61h
Hard for humans
High-level language
cout << "Hello";
Close to English (C++, Python, Java)
Module 2 · What Is Programming?
Programming Fundamentals · Lecture 1
Slide 10
Translators: Compiler vs Interpreter
C
Compiler
I
Interpreter
Translates the whole program at once, then runs it
Translates and runs one line at a time
Examples: C, C++
Examples: Python
Like translating a whole book before publishing it
Like a live translator at a conference
Module 2 · What Is Programming?
Programming Fundamentals · Lecture 1
Slide 11
How a C++ Program Runs
From source code to a running program
Write
Compile
Link
Executable
Run
hello.cpp
→ object code
+ libraries
hello.exe
see output
Errors? Fix the code and compile again
Module 2 · What Is Programming?
Programming Fundamentals · Lecture 1
Slide 12
Algorithm
A finite, step-by-step set of clear instructions to solve a problem
Properties
Example: Making chai
✓
Clear — no confusion
- Start
- Boil water
- Add tea leaves
- Add milk and sugar
- Boil for 2 minutes
- Pour into cup
- End
✓
Finite — it must end
✓
Has input and output
✓
Every step is doable
Module 3 · Problem Solving
Programming Fundamentals · Lecture 1
Slide 13
Example: Add Two Numbers
The same solution written two ways
Algorithm (plain steps)
Pseudocode
- Start
- Input number A
- Input number B
- Sum = A + B
- Display Sum
- End
- START
- READ A
- READ B
- SUM ← A + B
- PRINT SUM
- END
Module 3 · Problem Solving
Programming Fundamentals · Lecture 1
Slide 14
Flowchart Symbols
A flowchart is a picture of an algorithm
Terminal
Input / Output
Process
Decision
Start / End
Read / Print
Calculation
Yes / No question
Flow line (arrow) shows the direction of flow
Module 3 · Problem Solving
Programming Fundamentals · Lecture 1
Slide 15
Flowchart: Largest of Two Numbers
Start
Pseudocode
Read A, B
- START
- READ A, B
- IF A > B
- PRINT A
- ELSE
- PRINT B
- END
A > B ?
Yes
No
Print A
Print B
End
Slide 16
CLASS ACTIVITY · 5 MIN · IN PAIRS
Pass or Fail?
Input a student's marks. Print PASS if marks ≥ 50, otherwise print FAIL.
Write the algorithm
Draw the flowchart
Slide 17
Your First C++ Program
hello.cpp
Output
- #include <iostream>
- using namespace std;
- int main() {
- cout << "Hello, World!" << endl;
- return 0;
- }
Hello, World!
Try it: change the text to print your name and "I study at UAF"
Module 4 · First C++ Program
Programming Fundamentals · Lecture 1
Slide 18
Line by Line
Module 4 · First C++ Program
Programming Fundamentals · Lecture 1
Slide 19
Common Beginner Errors
Errors are normal — read the message, fix, compile again
!
Missing ;
!
Wrong case
cout << "Hi"
Cout << "Hi";
Compiler error on the next line
C++ is case-sensitive
!
Missing quotes
!
Missing }
cout << Hi;
int main() { ...
Text must be inside " "
Every { needs a matching }
Module 4 · First C++ Program
Programming Fundamentals · Lecture 1
Slide 20
Tools to Get Started
Dev-C++
Code::Blocks
Online compilers
Lightweight IDE for Windows; runs well on lab PCs
Free IDE for Windows and Linux
OnlineGDB or Programiz — work on any phone or browser
No laptop? No problem — an online compiler on your phone is enough to practise today.
Module 4 · First C++ Program
Programming Fundamentals · Lecture 1
Slide 21
Quick Recap
Answer aloud
Q1
What are the three parts of the IPO model?
Q2
Compiler vs interpreter — what is the difference?
Q3
Which shape is used for a decision in a flowchart?
Q4
Where does every C++ program start executing?
Slide 22
Homework
Algorithm + flowchart: area of a rectangle
Algorithm + flowchart: largest of THREE numbers
Install a compiler and print your name, roll number and department on separate lines
Next lecture: Variables, data types, and taking input with cin