SlideShare a Scribd company logo
1 of 31
CHAPTER 1
AN OVERVIEW OF COMPUTERS
AND PROGRAMMING
LANGUAGES
In this chapter, you will:
 Learn about different types of computers
 Explore the hardware and software components of a computer
system
 Learn about the language of a computer
 Learn about the evolution of programming languages
 Examine high-level programming languages
 Discover what a compiler is and what it does
 Examine how a high-level language program is processed
 Learn what an algorithm is and explore problem-solving
techniques
 Become aware of structured design and object-oriented design
programming methodologies
 Become aware of Standard C++ and ANSI/ISO Standard C++
A BRIEF OVERVIEW OF THE HISTORY OF
COMPUTERS
Computers that are in use can be classified in the following categories:
• Main frame computers.
• Mid size computers.
• Micro computers (also called personal computers).
ELEMENTS OF A COMPUTER SYSTEM
Hardware
CPU-The CPU has several components in it.
 CU - It has three main functions.
 Fetch and decode the instruction.
 Control the flow of information (instruction or data) in
and out of MM.
 Control the operation of the internal components of
CPU.
• PC-program counter points to the next instruction to be
executed.
• IR-instruction register holds the instruction that is currently
being executed.
• ALU-arithmetic logic unit. This component is responsible for
carrying out all arithmetic and logical operations.
• ACC-accumulator. Once ALU performs the operation the
results are placed in ACC.
Main Memory
 Directly connected to the CPU.
 All programs must be loaded into MM before they can be
executed.
 All data must be brought into MM before it can be manipulated.
 When the power of the computer is turned off every thing in the
main memory is lost for good.
Secondary storage
 Everything in main memory is lost when the computer is
turned off.
 Information stored in main memory must be transferred to
some other device for permanent storage.
 The device that stores information permanently is called
secondary storage.
 Examples of secondary storage are hard disks, floppy
disks, Zip disks,CD-ROMs, and tapes.
Input/Output devices
 For a computer to perform a useful task, it must be able to
take in data and programs and display the results of
calculations.
 The devices that feed data and programs into computers
are called input devices.
 The keyboard, mouse, and secondary storage are
examples of input devices.
 The devices that the computer uses to display results are
called output devices.
 A monitor, printer, and secondary storage are examples of
output devices.
Software
 Software are programs written to perform specific tasks.
 Two types of programs
 System programs - programs that take control of the
computer.
 Application programs - programs that perform a specific
task. (Word processors, spreadsheets, and games are
examples of application programs.)
THE LANGUAGE OF A COMPUTER
• Two types of electrical signal - analog and digital. Since inside
the computer digital signals are processed, the language of a
computer is a sequence of 0s and 1s.
• The language of a computer is called the machine language.
• The digit 0 or 1 is called a binary digit or in short form a bit.
• A sequence of 0s and 1s is also referred as a binary code.
Bit: A bit is a binary digit 0 or 1.
• A sequence of 8 bits is called a byte.
• Coding Scheme
• ASCII (American Standard Code for Information Interchange).
• 128 characters
•A is encoded as 1000001 (66th character)
•3 is encoded as 0110011.
• EBCDIC (used by IBM)-256 characters
• Unicode - 65536 characters. Two bytes are needed to store a
character.
THE EVOLUTION OF PROGRAMMING
LANGUAGES
 Early computers were programmed in machine language.
Suppose we want to represent the equation
wages = rate · hours
to calculate the weekly wages in machine language.
If 100100 stands for load, 100110 stands for multiplication and
100010 stands for store, then the following sequence of instructions
might be needed to calculate the weekly wages.
100100 0000 010001
100110 0000 010010
100010 0000 010011
Assembly languages - an instruction in assembly language is an easy-
to-remember form called a mnemonic.
Using the assembly language instructions, the equation to calculate the
weekly wages can be written as follows:
LOAD rate
MULT hour
STOR wages
Assembler: An assembler is a program that translates a program written in
assembly language into an equivalent program in machine language.
High level languages- Basic, FORTRAN, COBOL, Pascal,
C++, C
In order to calculate the weekly wages, the equation
wages = rate · hours
in C++, can be written as follows:
wages = rate * hours;
Compiler: A compiler is a program that translates a program written
in a high level language to an equivalent machine language.
PROCESSING A HIGH-LEVEL LANGUAGE
PROGRAM
The following steps are necessary to execute a program written in a
high level language, say, C++:
1. Use an editor to create a program (that is type) in C++. This program
is called the source program.
Source program: A program written in a high-level language.
2. Check that the program obeys the rules of the programming
language and translate the program in to an equivalent machine
language. All this is accomplished by the compiler. The equivalent
machine language program is called an object program.
Object program: The machine language version of the high-
level language program.
3. The programs that you write in a high-level language are
developed using a software development kit (SDK), which
contains many programs that are useful in creating your
program. This prewritten code resides in a place called the
library.
Linker: A program that combines the object program with other
programs provided by the SDK and used in the program to
create the executable code.
4. The next step is to load the executable program into the main
memory for execution and a program called loader
accomplishes this.
Loader: A program that loads an executable program into main
memory.
5. The final step is to execute the program.
PROGRAMMING WITH THE PROBLEM ANALYSIS–
CODING–EXECUTION CYCLE
• Programming is a process of problem solving.
• Problem solving techniques
 Analyze the problem
 Outline the problem requirements
 Design steps, called an algorithm, to solve the problem
Algorithm: A step-by-step problem-solving process in
which a solution is arrived at in a finite amount of time.
Problem solving process
1. (a) Analyze the problem.
(b) Outline the problem and its solution requirements.
(c) Design steps (algorithm) to solve the problem.
2. (a) Implement the algorithm in a programming language,
such as C++.
(b) Verify that the algorithm works.
3. Maintenance: Maintenance requires using and modifying the
program if the problem domain changes.
Problem Analysis-Coding-Execution Cycle
Analysis of the problem is the first and the most important step. This
phase requires us to:
1. Thoroughly understand what the problem is about.
2. Understand the problem requirements. Some of the
requirements could be:
a. Does the program require interaction with the user?
b. Does the program manipulate data? If the program manipulates
data, the programmer must know what the data are and how the
data are represented, that is, look at sample data.
c. Is there any output of the program? If yes, the programmer should
know how the results should be generated.
3. If the problem is complex, divide the problem into sub-
problems. Analyze each sub-problem as above.
• Dividing a problem into smaller subproblems is called
structured design.
• The structured design approach is also known as top-down
design, stepwise refinement, and modular programming.
• In structured design, the problem is divided into smaller
problems.
• Each subproblem is then analyzed, and a solution is obtained
to solve the subproblem.
• The solutions of all subproblems are then combined to solve
the overall problem.
• This process of implementing a structured design is called
structured programming.
• The next step is to design an algorithm to solve the problem.
• If the problem was broken into subproblems, design algorithms for
each subproblem.
• Once the necessary steps have been designed, check the correctness of
the algorithm.
• Sometimes algorithm’s correctness can be tested using sample data.
• At times some mathematical analysis might be required to test the
correctness of the algorithm.
• Once the algorithm is designed and correctness verified, the next step
is to write the equivalent code into the high level language.
• Then using an editor enter the program into the computer.
• The next step is to ensure that the program follows the constructs of
the language.
• Run the code through the compiler.
• If the compiler generates error, we must go back, look at the code,
remove the errors, and run the code again through the compiler.
• If there are no syntax errors, the compiler generates the equivalent
machine code, the linker links the machine code with the systems
resources, and the loader can then place the program into the main
memory so that it can be executed.
• The final step is to execute the program.
• The compiler only guarantees that the program follows the rules of the
language. It does not guarantee that the program will run correctly.
Example 1-1
Design an algorithm to find the perimeter and area of a
rectangle.
The perimeter and area of the rectangle are given by the
following formulas:
perimeter = 2 · (length + width)
area = length · width
The algorithm to find the perimeter and area of the rectangle
is, therefore:
1. Get the length of the rectangle.
2. Get the width of the rectangle.
3. Find the perimeter using the following equation:
perimeter = 2 · (length + width)
4. Find the area using the following equation:
area = length · width
Example 1-2
Design an algorithm that calculates the monthly paycheck of a sales-
person at a local department store.
Every salesperson has a base salary. The salesperson also receives a
bonus at the end of each month based on the following criteria: If the
salesperson has been with the store for five or less years, the bonus is
$10 for each year that he or she has worked there. If the salesperson has
been with the store for more than five years, the bonus is $20 for each
year that he or she has worked there. The salesperson can earn an
additional bonus as follows: If the total sale made by the salesperson for
the month is more than $5000 but less than $10000, he or she receives a
3% commission on the sale. If the total sale made by the salesperson for
the month is at least $10000, he or she receives a 6% commission on the
sale.
The algorithm to calculate a salesperson’s monthly paycheck.
1. Get baseSalary.
2. Get noOfServiceYears.
3. Calculate bonus using the following formula:
if(noOfServiceYears is less than or equal to
five)
bonus = 10 · noOfServiceYears
otherwise
bonus = 20 · noOfServiceYears
4. Get totalSale.
5. Calculate additionalBonus using the following formula.
if (totalSale is less than 5000)
additionalBonus = 0
otherwise
if(totalSale is greater than or equal to
5000 and totalSale is less than 10000)
additionalBonus = totalSale · (0.03)
otherwise
additionalBonus = totalSale · (0.06)
6. Calculate payCheck using the equation
payCheck = baseSalary + bonus + additionalBonus
OBJECT-ORIENTED PROGRAMMING
• In OOD, the first step in the problem-solving process is to identify
components called objects, which form the basis of the solution, and
determine how these objects interact with one another.
• After identifying the objects, the next step is to specify for each object
the relevant data and possible operations to be performed on that data.
• Each object consists of data and operations on that data.
• An object combines data and operations on the data into a single unit.
• A programming language that implements OOD is called an object-
oriented programming (OOP) language.
• Because an object consists of data and operations on that data, you
need to learn how to represent data in computer memory, how to
manipulate data, and how to implement operations.
• To create operations, you write algorithms and implement them in a
programming language.
• To work with objects, you need to know how to combine data and
operations on the data into a single unit.
• C++ was designed especially to implement OOD. Furthermore, OOD
works well and is used in conjunction with structured design.

More Related Content

Similar to 01CHAP_1.PPT

Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FITRaj vardhan
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptxchouguleamruta24
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingSangheethaa Sukumaran
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxHazardRhenz1
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages Ahmad Idrees
 
LKGtoPG - Basics of C Language
LKGtoPG - Basics of  C LanguageLKGtoPG - Basics of  C Language
LKGtoPG - Basics of C Languagelkgtopg jobs
 
System software module 1 presentation file
System software module 1 presentation fileSystem software module 1 presentation file
System software module 1 presentation filejithujithin657
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Conceptsimtiazalijoono
 
Computer and programming language
Computer and programming languageComputer and programming language
Computer and programming languageXad Kuain
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
PPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxPPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxUzma1102
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxTeddyDaka
 
Synapseindia dot net development computer programming
Synapseindia dot net development  computer programmingSynapseindia dot net development  computer programming
Synapseindia dot net development computer programmingSynapseindiappsdevelopment
 

Similar to 01CHAP_1.PPT (20)

Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FIT
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
CSC204PPTNOTES
CSC204PPTNOTESCSC204PPTNOTES
CSC204PPTNOTES
 
Program Logic and Design
Program Logic and DesignProgram Logic and Design
Program Logic and Design
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptx
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages
 
Lecture 2 - Introductory Concepts
Lecture 2 - Introductory ConceptsLecture 2 - Introductory Concepts
Lecture 2 - Introductory Concepts
 
LKGtoPG - Basics of C Language
LKGtoPG - Basics of  C LanguageLKGtoPG - Basics of  C Language
LKGtoPG - Basics of C Language
 
C program full materials.pdf
C program  full materials.pdfC program  full materials.pdf
C program full materials.pdf
 
System software module 1 presentation file
System software module 1 presentation fileSystem software module 1 presentation file
System software module 1 presentation file
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Concepts
 
Computer and programming language
Computer and programming languageComputer and programming language
Computer and programming language
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
PPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxPPS UNIT 1- R18.docx
PPS UNIT 1- R18.docx
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
 
Synapseindia dot net development computer programming
Synapseindia dot net development  computer programmingSynapseindia dot net development  computer programming
Synapseindia dot net development computer programming
 

Recently uploaded

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

01CHAP_1.PPT

  • 1. CHAPTER 1 AN OVERVIEW OF COMPUTERS AND PROGRAMMING LANGUAGES
  • 2. In this chapter, you will:  Learn about different types of computers  Explore the hardware and software components of a computer system  Learn about the language of a computer  Learn about the evolution of programming languages  Examine high-level programming languages  Discover what a compiler is and what it does  Examine how a high-level language program is processed  Learn what an algorithm is and explore problem-solving techniques  Become aware of structured design and object-oriented design programming methodologies  Become aware of Standard C++ and ANSI/ISO Standard C++
  • 3. A BRIEF OVERVIEW OF THE HISTORY OF COMPUTERS Computers that are in use can be classified in the following categories: • Main frame computers. • Mid size computers. • Micro computers (also called personal computers).
  • 4. ELEMENTS OF A COMPUTER SYSTEM Hardware CPU-The CPU has several components in it.  CU - It has three main functions.  Fetch and decode the instruction.  Control the flow of information (instruction or data) in and out of MM.  Control the operation of the internal components of CPU. • PC-program counter points to the next instruction to be executed. • IR-instruction register holds the instruction that is currently being executed. • ALU-arithmetic logic unit. This component is responsible for carrying out all arithmetic and logical operations. • ACC-accumulator. Once ALU performs the operation the results are placed in ACC.
  • 5.
  • 6. Main Memory  Directly connected to the CPU.  All programs must be loaded into MM before they can be executed.  All data must be brought into MM before it can be manipulated.  When the power of the computer is turned off every thing in the main memory is lost for good.
  • 7.
  • 8. Secondary storage  Everything in main memory is lost when the computer is turned off.  Information stored in main memory must be transferred to some other device for permanent storage.  The device that stores information permanently is called secondary storage.  Examples of secondary storage are hard disks, floppy disks, Zip disks,CD-ROMs, and tapes.
  • 9. Input/Output devices  For a computer to perform a useful task, it must be able to take in data and programs and display the results of calculations.  The devices that feed data and programs into computers are called input devices.  The keyboard, mouse, and secondary storage are examples of input devices.  The devices that the computer uses to display results are called output devices.  A monitor, printer, and secondary storage are examples of output devices.
  • 10. Software  Software are programs written to perform specific tasks.  Two types of programs  System programs - programs that take control of the computer.  Application programs - programs that perform a specific task. (Word processors, spreadsheets, and games are examples of application programs.)
  • 11. THE LANGUAGE OF A COMPUTER • Two types of electrical signal - analog and digital. Since inside the computer digital signals are processed, the language of a computer is a sequence of 0s and 1s. • The language of a computer is called the machine language. • The digit 0 or 1 is called a binary digit or in short form a bit. • A sequence of 0s and 1s is also referred as a binary code.
  • 12. Bit: A bit is a binary digit 0 or 1. • A sequence of 8 bits is called a byte. • Coding Scheme • ASCII (American Standard Code for Information Interchange). • 128 characters •A is encoded as 1000001 (66th character) •3 is encoded as 0110011. • EBCDIC (used by IBM)-256 characters • Unicode - 65536 characters. Two bytes are needed to store a character.
  • 13. THE EVOLUTION OF PROGRAMMING LANGUAGES  Early computers were programmed in machine language. Suppose we want to represent the equation wages = rate · hours to calculate the weekly wages in machine language. If 100100 stands for load, 100110 stands for multiplication and 100010 stands for store, then the following sequence of instructions might be needed to calculate the weekly wages. 100100 0000 010001 100110 0000 010010 100010 0000 010011
  • 14. Assembly languages - an instruction in assembly language is an easy- to-remember form called a mnemonic. Using the assembly language instructions, the equation to calculate the weekly wages can be written as follows: LOAD rate MULT hour STOR wages Assembler: An assembler is a program that translates a program written in assembly language into an equivalent program in machine language.
  • 15. High level languages- Basic, FORTRAN, COBOL, Pascal, C++, C In order to calculate the weekly wages, the equation wages = rate · hours in C++, can be written as follows: wages = rate * hours; Compiler: A compiler is a program that translates a program written in a high level language to an equivalent machine language.
  • 16. PROCESSING A HIGH-LEVEL LANGUAGE PROGRAM The following steps are necessary to execute a program written in a high level language, say, C++: 1. Use an editor to create a program (that is type) in C++. This program is called the source program. Source program: A program written in a high-level language. 2. Check that the program obeys the rules of the programming language and translate the program in to an equivalent machine language. All this is accomplished by the compiler. The equivalent machine language program is called an object program. Object program: The machine language version of the high- level language program.
  • 17. 3. The programs that you write in a high-level language are developed using a software development kit (SDK), which contains many programs that are useful in creating your program. This prewritten code resides in a place called the library. Linker: A program that combines the object program with other programs provided by the SDK and used in the program to create the executable code. 4. The next step is to load the executable program into the main memory for execution and a program called loader accomplishes this. Loader: A program that loads an executable program into main memory. 5. The final step is to execute the program.
  • 18.
  • 19. PROGRAMMING WITH THE PROBLEM ANALYSIS– CODING–EXECUTION CYCLE • Programming is a process of problem solving. • Problem solving techniques  Analyze the problem  Outline the problem requirements  Design steps, called an algorithm, to solve the problem Algorithm: A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time.
  • 20. Problem solving process 1. (a) Analyze the problem. (b) Outline the problem and its solution requirements. (c) Design steps (algorithm) to solve the problem. 2. (a) Implement the algorithm in a programming language, such as C++. (b) Verify that the algorithm works. 3. Maintenance: Maintenance requires using and modifying the program if the problem domain changes.
  • 22. Analysis of the problem is the first and the most important step. This phase requires us to: 1. Thoroughly understand what the problem is about. 2. Understand the problem requirements. Some of the requirements could be: a. Does the program require interaction with the user? b. Does the program manipulate data? If the program manipulates data, the programmer must know what the data are and how the data are represented, that is, look at sample data. c. Is there any output of the program? If yes, the programmer should know how the results should be generated. 3. If the problem is complex, divide the problem into sub- problems. Analyze each sub-problem as above.
  • 23. • Dividing a problem into smaller subproblems is called structured design. • The structured design approach is also known as top-down design, stepwise refinement, and modular programming. • In structured design, the problem is divided into smaller problems. • Each subproblem is then analyzed, and a solution is obtained to solve the subproblem. • The solutions of all subproblems are then combined to solve the overall problem. • This process of implementing a structured design is called structured programming.
  • 24. • The next step is to design an algorithm to solve the problem. • If the problem was broken into subproblems, design algorithms for each subproblem. • Once the necessary steps have been designed, check the correctness of the algorithm. • Sometimes algorithm’s correctness can be tested using sample data. • At times some mathematical analysis might be required to test the correctness of the algorithm. • Once the algorithm is designed and correctness verified, the next step is to write the equivalent code into the high level language. • Then using an editor enter the program into the computer.
  • 25. • The next step is to ensure that the program follows the constructs of the language. • Run the code through the compiler. • If the compiler generates error, we must go back, look at the code, remove the errors, and run the code again through the compiler. • If there are no syntax errors, the compiler generates the equivalent machine code, the linker links the machine code with the systems resources, and the loader can then place the program into the main memory so that it can be executed. • The final step is to execute the program. • The compiler only guarantees that the program follows the rules of the language. It does not guarantee that the program will run correctly.
  • 26. Example 1-1 Design an algorithm to find the perimeter and area of a rectangle. The perimeter and area of the rectangle are given by the following formulas: perimeter = 2 · (length + width) area = length · width
  • 27. The algorithm to find the perimeter and area of the rectangle is, therefore: 1. Get the length of the rectangle. 2. Get the width of the rectangle. 3. Find the perimeter using the following equation: perimeter = 2 · (length + width) 4. Find the area using the following equation: area = length · width
  • 28. Example 1-2 Design an algorithm that calculates the monthly paycheck of a sales- person at a local department store. Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month based on the following criteria: If the salesperson has been with the store for five or less years, the bonus is $10 for each year that he or she has worked there. If the salesperson has been with the store for more than five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an additional bonus as follows: If the total sale made by the salesperson for the month is more than $5000 but less than $10000, he or she receives a 3% commission on the sale. If the total sale made by the salesperson for the month is at least $10000, he or she receives a 6% commission on the sale.
  • 29. The algorithm to calculate a salesperson’s monthly paycheck. 1. Get baseSalary. 2. Get noOfServiceYears. 3. Calculate bonus using the following formula: if(noOfServiceYears is less than or equal to five) bonus = 10 · noOfServiceYears otherwise bonus = 20 · noOfServiceYears 4. Get totalSale.
  • 30. 5. Calculate additionalBonus using the following formula. if (totalSale is less than 5000) additionalBonus = 0 otherwise if(totalSale is greater than or equal to 5000 and totalSale is less than 10000) additionalBonus = totalSale · (0.03) otherwise additionalBonus = totalSale · (0.06) 6. Calculate payCheck using the equation payCheck = baseSalary + bonus + additionalBonus
  • 31. OBJECT-ORIENTED PROGRAMMING • In OOD, the first step in the problem-solving process is to identify components called objects, which form the basis of the solution, and determine how these objects interact with one another. • After identifying the objects, the next step is to specify for each object the relevant data and possible operations to be performed on that data. • Each object consists of data and operations on that data. • An object combines data and operations on the data into a single unit. • A programming language that implements OOD is called an object- oriented programming (OOP) language. • Because an object consists of data and operations on that data, you need to learn how to represent data in computer memory, how to manipulate data, and how to implement operations. • To create operations, you write algorithms and implement them in a programming language. • To work with objects, you need to know how to combine data and operations on the data into a single unit. • C++ was designed especially to implement OOD. Furthermore, OOD works well and is used in conjunction with structured design.