0% found this document useful (0 votes)
49 views71 pages

CS114 - Fundamentals of Programming

Here is a more complex problem: You are developing an ATM machine program. The program should: 1. Ask the user to insert their debit card and enter their PIN. 2. Display a menu with options to check balance, withdraw cash, deposit cash, and exit. 3. Validate the user's selection and process the requested transaction. This may involve checking balances, dispensing cash, recording deposits, and updating balances. 4. Provide receipts for the transactions and allow the user to perform multiple transactions in one session before exiting. 5. Include appropriate error handling and messages if invalid selections or data are entered. How would you go about solving this problem?

Uploaded by

Abdullah Riasat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views71 pages

CS114 - Fundamentals of Programming

Here is a more complex problem: You are developing an ATM machine program. The program should: 1. Ask the user to insert their debit card and enter their PIN. 2. Display a menu with options to check balance, withdraw cash, deposit cash, and exit. 3. Validate the user's selection and process the requested transaction. This may involve checking balances, dispensing cash, recording deposits, and updating balances. 4. Provide receipts for the transactions and allow the user to perform multiple transactions in one session before exiting. 5. Include appropriate error handling and messages if invalid selections or data are entered. How would you go about solving this problem?

Uploaded by

Abdullah Riasat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

CS114 – Fundamentals of programming

Overview

Introduction

Course details

Assessment

What is this course about?

Aims and Outcomes


Introduction

 Instructor: Aisha Shabbir


 Consultation Hours
 During office hours but it will be best if you take an appointment by
email first
 Email: [email protected]
 Office: 115, NIT Building
Introduction

 Brief Introduction of students


 Name

 Qualification

 Day Scholar/ Hostelite

 % in FSc/A-Levels

 Your aim/aspiration in life

 Expectation from this course


Course Details
CREDITS: 2+1
Course Details

 Credits: 2+1
 Grade distribution is (67% + 33%)
• Theory – 67%
• Quizzes – 15%
• Assignments – 10%
• OHT-1 – 15%
• OHT-2 – 15%
• ESE – 45%
• Practical – 33%
• Lab Work – 70%
• Lab Project/Exam – 30%
Course Description

 An introduction to the development of programs using


C++.
 Emphasis is given to the development of program
modules that can function independently.
What is this course about?

 Problem solving
 Designing solutions using flowcharts
 Basic computer programming using C/C++
 Python
 Logic building & algorithms
Text Book

 Book
 There are many books on C/C++

 All of them teach almost the same thing


Text Book
Reference Book
Course Contents

Week Topics
1 Introduction to Course, Introduction to Computer: System components,
networks and operating systems
Lab: Computer Hardware and Operating System

2 Introduction to Logic, Flow Charts, Pseudo Code, Introduction to Programming


Lab: Problem Solving using Flow Charts (Visual Logic), Testing the
Programming Environment and Basic Program
3 Programming Environment, Basic Programming, Statements, Expressions,
Comments
Lab: First Program, Basic statement, and Output Formats
4 First Program, Compilation, Variables, Types, Operators, Debugging
Lab: Variable processing, Arithmetic operations, Finding Errors
5 I/O, interactive programming
Lab: User Input based programming
6 OHT – I
Course Contents
Week Topics
7 Relational operators, logical operators, conditional statements
Lab: Conditional Constructs I
8 If-Else Statement, Switch-Break-Continue
Lab: Conditional Constructs II
9 Iterations, For loop, Do-While Loop, While Loop
Lab: Loops and Iterations
10 Functions, parameters to functions
Lab: Function Definition, Function Parameters and calls
11 More functions, Recursion
Lab: Function reuse and recursion
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

By the end of the course, you should be able to:


1. Comprehend the fundamental concepts of computer
systems.
2. Apply programming skills to implement computer-
based solutions of well specified problems.
3. Analyze where computer programs fit in the provision
of computer-based solutions to real world problems.
Attendance Policy

 Will be marked at the beginning of the class (within first


10 mins)
 75% required to take ESE
 Any missed attendance is your own responsibility
 No late attendance marking
Quiz Policy

 5-6 quizzes in whole semester


 Unannounced
Assignment Policy

 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

 Each student will submit their own work at the end of


each lab
 No late/email submissions will be accepted
 Zero tolerance for plagiarism/cheating
 Discussing lab task is fine, but you must submit your own work.
 Pop Lab Quiz – which can be unannounced, you should
expect a lab quiz after every 3/4 lab sessions.
Student Civility

 In an effort to make this class enjoyable for everybody…


 Please be on time to class!
 Please do not talk to your friends and neighbors in class! It disturbs
everyone, and makes it hard to concentrate. If you have a question,
just ask me!
 Please turn your cell-phones off! No usage of mobiles during class –
will have a penalty.
 Interaction is the key
 Please ask questions
 If you don’t understand, ask
 Let me know if I am going too slow/too fast
Road Map for Today
• Computer Programming in Civil Engineering
• History of Computers
• Introduction to Computers
• Introduction to Programming
Why study Computer
Programming in Civil Engineering?
HISTORY OF COMPUTERS
Hardware and Software
• Charles Babbage
Creator of the Analytical Engine - the first
general-purpose digital computer (1833)

• ENIAC - the Analytical Engine was not built


(courtesy : Wikipedia.org)
until 1945 (Harvard Mark I)
– World’s first programmable computer
– Could carryout any calculation
– CPU was 8 feet tall , 100 feet long and
weighed 30 tons

(courtesy of US Army Historic Computer


Images)
History of Computers

• Ada (1815-52)
Wrote a program for computing the
Bernoulli’s sequence on the Analytical
Engine - world’s 1st computer program
INTRODUCTION TO
COMPUTERS

A device that can


perform
computations and
make logical
decisions
Motherboard
Input
devices
Processing
devices

Quratulain Shafi
Memory
devices

RAM:
Volatile memory

ROM:
Non-volatile
memory
Storage Magnetic storage:
devices Hard disks
Non-volatile memory

IDE - Integrated SCSI - Small Computer


Drive Electronics Systems Interface
Storage Optical storage:
devices CD/ DVD
Non-volatile memory
Output
devices
Communication
devices
System
Software

Name some other Operating


Systems
Application
Software
A Layered View of the Computer
Application Programs
Word-Processors, Spreadsheets,
Database Software, IDEs,
etc…
System Software
Compilers, Interpreters, Preprocessors, etc.
Operating System, Device Drivers

Machine with all its hardware


Can computers think?
Even the most powerful
supercomputers require
!
human interaction
1. Setting up the system

2. Installing software

3. Running programs
4. Managing files
5. Maintaining the system
Commonly used
Programming languages

Basic
Microsoft

Pascal
Perl
Cobol
.Net
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 easy to learn or not?????

C++

C
DevC++
• We will be using DevC++
• Full-featured Integrated Development Environment
(IDE)
• Home task:
– Download and install DevC++ on your PCs from:
http://www.bloodshed.net/dev/devcpp.html
INTRODUCTION TO
PROGRAMMING

Computer has to
be precisely told
what it needs to
do; otherwise
Program
• Programs are everywhere on the computer and
internet

• Even operating systems are


programs
Program
“a precise sequence of steps to solve a
particular problem”

• Programs run or executed (like OS runs on


Hardware like laptop or cell phone)
• Programs can also be run by other programs (like
when we play games in a web browser)
Program design
Hierarchy chart

Program
Flow chart
Designing
Pseudo Code

Source Code Machine Code


Program coding
Hierarchy chart

Flow chart

Pseudo Code

Source Code Machine Code


Program design

Hierarchy Chart
Program design

2 ways to show details:

i) Pseudocode: describes logic and processing


flow in human-language statements

ii) Flow chart: graphically represents logic flow.

Most projects use both methods


Problem Solving
Problem Solving

 Understand the Problem


 Knowledge of the problem, its domain, & details

 Devising the Plan


 Thinking of possible solutions

 Carrying out the Plan


 Create retraceable steps

 Looking Back
 Compare solution to problem. Improve.
Problem

I say a number between 1 and 70.


If the number is less than 30, you say “Too Young”,
otherwise say “Old”.
OR
ATM machine transactions
What happened there?!

 Understand
 Too simple

 Plan
 Too simple

 Carry out the Plan


 Too simple

 Looking Back
 Why too simple?
New Problem

Take the problem “ I say a number between 1 and 70. If the


number is less than 30, you say “Too Young”, otherwise say “Too
Old”. ” and provide a solution so that a machine could do the same
what you did.

 Understand, Plan, Solve, Look back.


Representing your solution

 There are 2 ways to represent

 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

 Pseudo Code can be generic or language specific

 Works as a planning tool

 Clarifies the algorithm flow of information

 Makes it easier to generate language syntax


Flow Chart

 Same as a pseudo code but graphical

 Easier to read and understand

 Specific symbols to represent different programming constructs


Flow Chart Symbols

 Flow charts are used in many domain, hence have numerous


symbols
 Some basic are:
Flow Chart Symbols
Flow Chart Example
Program design
START Convert START
STOP Centigrade to
Fahrenheit
PSEUDOCODE:
PROCESS inputCent
Display “Enter Centigrade: " centigrade

Input INPUT
centigrade
OUTPUT calcFah
fahrenheit = 1.8 * centigrade + 32= (1.8*centigrade) + 32
fahrenheit

Display “Centigrade to Fahrenheit = " fahrenheit


CONNECTOR
outputFah
fahrenheit
FLOW LINES

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 ]

You might also like