CS114 - Fundamentals of Programming: Qurrat-Ul-Ain Babar
CS114 - Fundamentals of Programming: Qurrat-Ul-Ain Babar
Q U R R AT- U L - A I N B A B A R
Overview
Introduction
Course details
Assessment
Credits: 2+1
Grade distribution is (67% + 33%) Content
• Theory – 67%
• OHT
• ESE
• Practical – 33%
• Lab Work – 70%
• Lab Project/Exam – 30%
Lecture Lab
Course Description
Problem solving
Designing solutions using flowcharts
Basic computer programming using C/C++
Logic building & algorithms
Text Book
Book
There are many books on C/C++
All of them teach almost the same thing
12 OHT – II
Course Contents
Week Topics
13 Arrays
Lab: Arrays and Operations on Arrays
14 Structures
Lab: Structure definition and usage
15 Pointers
Lab: Pointers, Variable Pointer
16 File I/O
Lab: File Handling and Information storage
17 Project demos, Revision
Lab: Project Demos
18 ESE
19 ESE
Course Outcomes
3 - 4 Assignments
No drop policy
No late/email submissions will be accepted
Zero tolerance for plagiarism/cheating
Discussing homework concepts is fine, but you must submit your
own work.
Lab Tasks Policy
• Ada (1815-52)
Wrote a program for computing the
Bernoulli’s sequence on the Analytical
Engine - world’s 1st computer program
INTRODUCTION TO
COMPUTERS
RAM:
Volatile memory
ROM:
Non-volatile
memory
Storage Magnetic storage:
devices Hard disks
Non-volatile memory
Perl
Basic
Pascal
Cobol
Microsoft
Net C++
C Python
We teach C++, Why?
• C++ is one of the most popular languages
– C++ (originally C)
• C++ is portable (runs on Windows, Macintosh, Unix,
Mainframes …)
• C++ is widely used in industries
• C++ is not easy to learn
C++
C
DevC++
• We will be using DevC++
• Full-featured Integrated Development Environment
(IDE)
• Home task:
– Download and install DevC++ on your PCs
INTRODUCTION TO
PROGRAMMING
Computer has to
be precisely told
what it needs to
do; otherwise
Program
• Programs are everywhere on the computer and
internet
Flow chart
Program
Designing
Pseudo Code
Flow chart a m
g r
r o ng
P d i
Pseudo Code
C o
Hierarchy Chart
Program design
Understand
Rectangle
Length of sides 24x20m
Posts 4 meters apart
Number of posts?
Plan
Drawing a diagram may help
Start from corner posts perhaps
Fence Problem Solution
Solve
Draw rectangle
Show sides to scale
Place corner posts
Place posts 4 meters apart
Count posts
Look Back
Can you solve it in a better way?
Problem
Understand
Squares tables, 1 person on each side
Form a large rectangle
22 people
Putting them together will reduce the number of people on each
square table
Plan
Drawing pictures of different arrangements may help
Few possibilities: 1 single row, 2 rows perhaps
Dinner Party Problem Solution
Looking Back
Single row configuration will be best, given the room is long
enough to hold it.
What if the number of people is increased to 38?
Another Problem
Understand
Too simple
Plan
Too simple
Carry out the Plan
Too simple
Looking Back
Why too simple?
Human Intelligence
O. Why ?
N
They need instructions
• Accurate
• In order
New Problem
Pseudo code
An English‐like representation of logical steps to solve a problem.
Flowchart
Pictorial representation of the same thing.
Pseudo Code
BEGIN
GET number
IF number less than 30 THEN
Say “Too Young”
ELSE
Say “Too Old”
ENDIF
END
Corrected Pseudo Code
BEGIN
GET number
IF number greater or equals 1 AND number less or equals 70 THEN
IF number less than 30 THEN
Say “Too Young”
ELSE
Say “Too Old”
ENDIF
ELSE
Say Invalid Input
ENDIF
END
Pseudo Code
Input INPUT
centigrade
OUTPUT calcFah
fahrenheit = 1.8 * centigrade + 32= (1.8*centigrade) + 32
fahrenheit
STOP
• Write pseudo code and draw a flowchart that
will read the two sides of a rectangle (length
and width) and display its area on screen after
calculation. [Area formula: A = L x W ]