Programming Fundamentals
Presented By:
Muhammad Raees
Course Objectives
The aim is not to make you the expert of computer
programming but only the basics of computer
programming.
To familiarize students with the use of C++.
To equip students with tools and techniques to implement
a given problem programmatically
Why this Course?
Recommended Book
Problem Solving with C++ 10th edition by Walter Savitch-
Pearson Prentice-Hall
C++ Programming from Problem Analysis to Program
Design, 7th Edition, By, DS Malik
Programming in C++ by Dietel and Dietal
Programming in C++ by Robert Laphore
Lecture Handouts
IDEs used for this course
You can use any of the IDEs given below; but we will use
Dev C++ in the classes and Labs
DEV C++
Visual C++
Turbo C++
Grading Criteria
▪ As per University Policy
▪ Theory + Practical
▪ (3hours Class+3hours Lab) Per Week
Topics to be Covered
➢ Computer Systems
➢ Programing & Problem Solving
➢ Introduction to C++
Computer Systems
Let’s Discuss some basics
Computer Systems
Hardware: Physical devices (Which can be touched
and see)
Software: Instructions and computer programs (only
see but cannot touch physically)
Computer is an electronic machine/device which
accepts data as an input, performs processes on the
data and gives information as result.
Computer (Continued)
Computer: A programmable, electronic device that accepts data,
performs operations on that data, and stores the data or results as
needed
Computers follow instructions, called programs, which
determine the tasks the computer will perform
Basic operations
Input: Entering data into the computer
Processing: Performing operations on the data
Output: Presenting the results
Storage: Saving data, programs, or output for future
use
Communications: Sending or receiving data
Computer Diagram
(Working)
Computer In Depth
Processing
Devices
Communication
Devices
Hardware Storage Devices
Input Devices
Computer Output Device
System Software
Application
Software
Software
Developmental
Software
Hardware in Detail
Software
Explore your mobile……..
Main Components of a
Computer
Software
Instructions for the hardware.
▪ Actions to be performed
A set of instructions is called a program.
▪ Driving force behind the computer
▪ Without a program – What is a computer?
▪ Collection of Useless Hardware
2 purposes:
▪ Tell the computer what to do
▪ Tell other people what we want the computer to do.
Programming Language
Digital devices have two stable states, zero and one
A single digit (0 or 1) is called a bit, short for binary digit. A byte is
made up of 8 bits.
Binary Language: Data and instructions (numbers, characters,
strings, etc.) are encoded as binary numbers - a series of bits, called
byte.
Programming Languages
Computers can not use human languages, and programming in
the binary language of computers is a very difficult process
Therefore, most programs are written using a programming
language and are converted to the binary language used by
the computer
Three major categories of prog languages:
Machine Language
Assembly Language
High level Language
Machine Language
Natural language of a particular computer
Primitive instructions built into every computer
The instructions are in the form of binary code
Any other types of languages must be translated
down to this level
Example: 0110 1001 1010 1011
Assembly Languages
English-like Abbreviations used for operations ADD X Y
Z
Assembly languages were developed to make
programming easier
The computer cannot understand assembly language
- a program called assembler is used to convert
assembly language programs into machine code
High Level Languages
English-like and easy to learn and program
Common mathematical notation
Total Cost = Price + Tax;
area = 5 * 5 * 3.1415;
Java, Python,C, C++, FORTRAN,COBOL, VISUAL BASIC,
PASCAL
Compilers
A compiler is a program that translates a high-level
language program, such as a C++ program, into a
machine-language program that the computer can
directly understand and execute.
Programming and Problem-Solving
What is Program and
Programming ?
Program is a set of instructions, which performs any
particular task.
Programming is a process of problem solving. Different
people use different techniques to solve problems
Problem Solving
The process of defining a problem, searching for
relevant information and resources about the
problem, and of discovering, designing, and
evaluating the solutions for further opportunities.
Includes:
▪ Finding an Answer to a Question
▪ Figuring out how to Perform a Task
▪ Figure out how to Make Things Work
Not enough to know a particular programming
language… Must be able to problem solve…
Polya’s 4 Steps of Problem
Solving
Problem Solving Phase
U – Understand the Problem
D – Devise a Good Plan to Solve
Implementation Phase
I – Implement the Plan
E – Evaluate the Solution
Example
Determine how many times a name occurs in a list of
names:
Example
Determine how many times a name occurs in a list of names:
1. Get the list of names.
2. Get the name being checked.
3. Set a counter to zero.
4. Do the following for each name on the list: Compare the
name on the list to the name being checked, and if the
names are the same, then add one to the counter.
5. Announce that the answer is the number indicated by
the counter.
The instructions numbered 1 through 5 is algorithm
Algorithm
A sequence of precise instructions which leads to a
solution is called an algorithm.
Some approximately equivalent words are recipe,
method, directions, procedure, and routine.
Class Activity
Program Design
To produce a program in a programming language
such as C++, the algorithm is translated into the
programming language. Producing the final program
from the algorithm is called the implementation phase.
Introduction to C++
History and Introduction to
C++
C++ is a programming language
It was developed by Dennis Riche at Bell’s Lab in
1971.
In C++, we can make new software or programs.
History and Introduction to
C++
Before C++, there were so many languages which were
being used by the programmers like GW Basic, Pascal,
and Fortran etc. But after the birth of C++, it becomes
more famous than all other languages. So many of the
programmers divorced the other languages and happily
married with C++.
Features of C++ Language
C++ is considered as High level language.
C++ is case sensitive language.
C++ has compiler as a language translator.
C++ is hybrid language (Combination of
structured as well as Object orientation
paradigm)
Terminologies
Computer Programming:
The process of developing and implementing
various sets of instructions to enable a computer to do a certain task is
called Computer Programming.
Computer Program:
A program is a set of step-by-step instructions that directs the computer
what to do and how to do.
Computer Programmer:
The one who is expert in writing computer programs or developing the
software is called a computer programmer or developer.
Programming Language:
A programming language is a formal constructed language designed to
communicate instructions to a machine, particularly a computer.
IDEs
An integrated development environment is a software
application that provides comprehensive facilities to
computer program
An IDE normally consists of at least a source code
editor, build automation tools, and a debugger.
Editor, Linker, Loader,
Compiler, Debugger
IDE has editor, linker, compiler, loader, executer and
debugger.
Editor: In editor we write the source code.
Compiler: Converts the source code in to machine code.
Linker: Linker links the object code with libraries.
Loader: Loader loads program in to the memory.
Executer: This unit executes the program.
Debugger: This unit helps in removing the defect or
errors or logical errors.
Recap of the lecture
•Introduction to Computer
•What is Program ?
•History and Development of C-Language
•Features of C-Language
•Level and Generations of Programming Languages
•Terminologies
Recommended Readings
Chapter No. 1 of
Problem Solving with C++ 10th edition by Walter Savitch-
Pearson Prentice-Hall
&
C++ Programming from Problem Analysis to Program Design
written by DS Malik