0% found this document useful (0 votes)
9 views

C++ INTRO

Uploaded by

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

C++ INTRO

Uploaded by

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

Lecture #1

INTRODUCTION TO COMPUTER PROGRAMMING, CS-201

Topic: “Introduction to Programming”

BOOK: Deitel & Deitel – C++ How to Program


(10 th Edition)
Chapter 1: 1.2, 1.3, 1.4, 1.6, 1.7

101 EC
20/05/2024 Total no. of slides = 14
Learning Objectives

After the lesson learners will learn about

Computer and its organization


Programming
Different computer programming languages
History

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
What is a Computer?
◦ A computer is an electronic device that takes input from the user and
processes these data under the control of a set of instructions (called a
program) gives the result (output) and saves it for future use. It can
process both numerical and non-numerical (arithmetic and logical)
calculations.
◦ Hardware – various devices comprising a computer
◦ Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units

◦ Software – programs that run a computer

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
Computer Organization

◦ Six logical units in every computer:


1. Input unit
◦ obtains information from input devices (keyboard, mouse)
2. Output unit
◦ outputs information (to screen, to printer, to control other devices)
3. Memory unit
◦ rapid access, low capacity, stores input information
4. Arithmetic and logic unit (ALU)
◦ performs arithmetic calculations and logic decisions

5. Central processing unit (CPU)


◦ supervises and coordinates the other sections of the computer

6. Secondary storage unit


◦ cheap, long-term, high-capacity storage, stores inactive programs

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
What is programming?
Definition:
"A program is a precise sequence of steps to solve a particular
problem.”
It means that when we say that we have a program, it actually means
that we know about a complete set activities to be performed in a
particular order. The purpose of these activities is to solve a given
problem.

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
Machine Languages, Assembly Languages, and High-level
Languages

◦ Three types of programming languages


1. Machine language (Low-level language)

2. Assembly languages

3. High-level languages (C, C++ and C# etc)

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
1. Machine language (Low-level language)

– Strings of numbers giving machine specific instructions


– It is a series of numbers, which is not easy for humans to read.
– Example:
1111000
1010101
1100110

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
2. Assembly languages (Low-level language)

– English-like abbreviations
representing elementary
computer operations
(Mnemonics translated via
assemblers)
– Programmers can write human-
readable programs that
correspond almost exactly to
machine language.
– Example:
MOV TOTAL, 48 ; Transfer the
value 48 in the memory variable
TOTAL
ADD AH, BH ; Add the content
of the BH register into the AH
register
AND MASK1, 128 ; Perform AND
operation on the variable MASK1
and 128

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
3. High-level languages

◦ Similar to everyday English and use mathematical notations (translated


via compilers) like C, C++ and C#.
◦ Example:
grossPay = basePay + overTimePay

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
Some other High-level Languages
◦ A few other high-level languages have achieved broad acceptance
◦ FORTRAN
◦ for scientific and engineering applications
◦ COBOL
◦ used to manipulate large amounts of data
◦ Pascal
◦ intended for academic use
◦ C++
◦ advance version of C. applications in accounting and finance systems
◦ Java
◦ used over the internet.
◦ PL/1
◦ Programming Language one. Designed to use the key features of FORTRAN,
COBOL and ALGOL.

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
Language translators

◦ Any program written in a high level languageis known as source code.


However, computers cannot understand source code. Before it can be
run, source code must first be translated into a form which a computer
understands - this form is called object code.
◦ A translator is a program that converts source code into object code.
Generally, there are three types of translator:

compilers

interpreters

assemblers

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
History of C++

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
History of C++
◦ C++ evolved from C, which evolved from two previous programming
languages, BCPL (Basic Combined Programming Language) and B.

◦ C++ programs consist of pieces called classes and functions

◦ There are rich collections of existing classes and functions in the C++
standard library available for all programmers to use.

◦ C++ “spruces up” C and provides capabilities for object-oriented


programming
◦ objects - reuseable software components, model things in the real world

◦ Object-oriented programs are easy to understand, correct and modify

Bjarne Stroustrup, AT&T New Jersey office, c.


2000
Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,
Practice Exercise
Q #1: Differentiate between C and C++ language. Also explain that why C is called
structural/procedural language and C++ is called an object oriented programming
language.
Q #2: Differentiate between Interpreter and Compiler. Give example in each case.

◦ Useful links:
 https://www.youtube.com/watch?v=UdTzHmjMYBc
 https://www.youtube.com/watch?v=JBjjnqG0BP8
 https://www.youtube.com/watch?v=jsYLwJNv4l4

Bjarne Stroustrup,
Professor of Computer Science,

Columbia University, July 2022.

Asst. Prof. Dr SALAHUDDIN, School of Humanities and Sciences (S H & S), NUST, PAF Asghar Khan Academey,

You might also like