SlideShare uma empresa Scribd logo
1 de 26
An Introduction to
Programming with C++
Sixth Edition
Chapter 1
An Introduction to Programming
Objectives
• Define the terminology used in programming
• Explain the tasks performed by a programmer
• Describe the qualities of a good programmer
• Understand the employment opportunities for
programmers and software engineers
• Explain the history of programming languages
An Introduction to Programming with C++, Sixth Edition 2
Objectives (cont’d.)
• Explain the sequence, selection, and repetition
structures
• Write simple algorithms using the sequence,
selection, and repetition structures
An Introduction to Programming with C++, Sixth Edition 3
Programming a Computer
• Programs are the directions given to computers
• Programmers are the people who write computer
programs
• Programming Languages enable programmers to
communicate with the computer
• Popular languages: C++, Visual Basic, C#, Java
• How are these languages used commercially?
An Introduction to Programming with C++, Sixth Edition 4
The Programmer’s Job
• Programmers help solve computer problems
• Employee or freelance
• Typical steps involved
– Meet with user to determine problem
– Convert the problem into a program
– Test the program
– Provide user manual
An Introduction to Programming with C++, Sixth Edition 5
An Introduction to Programming with C++, Sixth Edition 6
Do I Have What It Takes to Be a
Programmer?
• Qualities employers look for
– Logical and analytical thinking
– Close attention to detail
– Patience and persistence
– Ingenuity and creativity
– Good communication skills: technical and
nontechnical
– Business skills (for managerial positions)
Employment Opportunities
• Computer software engineer: designs an
appropriate solution to a user’s problem
• Computer programmer: codes a computer solution
• Coding is the process of translating a computer
solution into a language a computer can
understand
• Some positions call for both engineering and
programming
An Introduction to Programming with C++, Sixth Edition 7
A Brief History of Programming
Languages
• Enable programmer to communicate with computer
• Different types
– Machine languages
– Assembly languages
– High-level languages
An Introduction to Programming with C++, Sixth Edition 8
An Introduction to Programming with C++, Sixth Edition 9
Machine Languages
• The first programmers had to write the program
instructions using only combinations of 0s and 1s
– Example: 00101 10001 10000
• Instructions written in 0s and 1s are called
machine language or machine code
• Each type of machine has its own language
• Machine languages are the only way to
communicate directly with the computer
• Programming in machine language: tedious and
error-prone; requires highly trained programmers
An Introduction to Programming with C++, Sixth Edition 10
Assembly Languages
• Assembly languages simplify programmer’s job
• Can use mnemonics instead of 0s and 1s
– Example: ADD bx, ax
• Assembly programs require an assembler to
convert instructions into machine code
• Easier to write programs in assembly language
– But still tedious and requires highly trained
programmers
An Introduction to Programming with C++, Sixth Edition 11
High-Level Languages
• High-level languages allow programmer to use
English-like instructions
– Example: grossPay = hours * rate
– High-level languages are more machine independent
• Programs written in a high-level language can be used
on many different types of computers
• Compilers translate high-level instructions into 0s
and 1s (machine language)
• Interpreters translate the program line by line as
the program is running
An Introduction to Programming with C++, Sixth Edition 12
High-Level Languages (cont’d.)
• When writing a procedure-oriented program, the
programmer concentrates on the major tasks that
the program needs to perform
– Examples: COBOL, BASIC, C
• An object-oriented program requires programmer
to focus on the objects that the program can use to
accomplish its goal
– Examples: C++, Visual Basic, Java, C#
• Object-oriented programs allow for better code-
reuse
– An object can be used in more than one program
An Introduction to Programming with C++, Sixth Edition 13
Control Structures
• Programs are written using three basic structures
– Sequence
• Used in every program you write
– Repetition
• Used in most programs you write
– Selection
• Used in most programs you write
• These are called control structures or logic
structures
An Introduction to Programming with C++, Sixth Edition 14
The Sequence Structure
• The sequence structure directs the computer to
process the program instructions, one after
another, in the order listed in the program
• An algorithm is a set of step-by-step instructions
that accomplish a task
• Example: following a recipe to make cookies
The Sequence Structure (cont’d.)
An Introduction to Programming with C++, Sixth Edition 15
Figure 1-1 An example of the sequence structure
An Introduction to Programming with C++, Sixth Edition 16
The Selection Structure
• Selection structure: makes a decision and then
takes an appropriate action based on that decision
– Also called the decision structure
• Example: waiting or crossing at railroad tracks
depending on signal lights
The Selection Structure (cont’d.)
An Introduction to Programming with C++, Sixth Edition 17
Figure 1-2 An example of the selection structure
An Introduction to Programming with C++, Sixth Edition 18
The Selection Structure (cont’d.)
Figure 1-3 Another example of the selection structure
An Introduction to Programming with C++, Sixth Edition 19
The Repetition Structure
• Repetition structure: directs computer to repeat
one or more instructions until some condition is met
– Also called a loop or iteration
Figure 1-4 Modified algorithm showing the repetition structure
An Introduction to Programming with C++, Sixth Edition 20
The Repetition Structure (cont’d.)
• What could you do if you don’t know precisely how
many steps separate Robin from the boxes?
Figure 1-5 Algorithm showing the modified condition in the repetition structure
Summary
• Programs are step-by-step instructions that tell a
computer how to perform a task
• Programmers use programming languages to
communicate with the computer
– First programming languages were machine
languages: 0s and 1s (machine code)
– Next came assembly languages, which allowed for
mnemonics
– High-level languages can be used to create
procedure-oriented programs or object-oriented
programs
An Introduction to Programming with C++, Sixth Edition 21
Summary (cont’d.)
• Algorithm: step-by-step instructions that
accomplish a task (not written in a programming
language)
– Algorithms contain one or more of the following
control structures: sequence, selection, and
repetition
• Sequence structure: process the instructions, one
after another, in the order listed
• Selection structure: directs the computer to make a
decision and then to select an appropriate action
based on that decision
• Repetition structure: repeat one or more
instructions until some condition is met
An Introduction to Programming with C++, Sixth Edition 22
YOUR Assignments –
Lab 1-1: Stop and Analyze
• A local business employs five salespeople and
pays a 3% bonus on a salesperson’s sales
• Your task is to create a program that calculates the
amount of each salesperson’s bonus
• The program should print each salesperson’s name
and bonus amount
An Introduction to Programming with C++, Sixth Edition 23
An Introduction to Programming with C++, Sixth Edition 24
YOUR Assignments –
Lab 1-2: Plan and Create
• Using only the instructions shown below, create an
algorithm that shows the steps an instructor takes
when grading a test that contains 25 questions
An Introduction to Programming with C++, Sixth Edition 25
YOUR Assignments –
Lab 1-3: Modify
• Modify the algorithm shown in Lab 1-1 so that it
gives a 3.5% bonus to salespeople selling more
than $2,000
• All other salespeople should receive a 3% bonus
Your Assignments -
Labs –
– Lab 1 – Stop and Analyze
– Lab 2 - Plan and Create
– Lab 3 – Modify
Review Questions – pages 13-15
Chapter 1 – Exercises – Pages 15-19
An Introduction to Programming with C++, Sixth Edition 26

Mais conteúdo relacionado

Mais procurados (20)

C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
 
C++ Tutorial
C++ TutorialC++ Tutorial
C++ Tutorial
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
C programming notes
C programming notesC programming notes
C programming notes
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
A Crash Course in C Part-1
A Crash Course in C Part-1A Crash Course in C Part-1
A Crash Course in C Part-1
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
C programming language
C programming languageC programming language
C programming language
 
C++ for beginners
C++ for beginnersC++ for beginners
C++ for beginners
 
C Programming - Refresher - Part IV
C Programming - Refresher - Part IVC Programming - Refresher - Part IV
C Programming - Refresher - Part IV
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
C++ ch1
C++ ch1C++ ch1
C++ ch1
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 

Semelhante a First draft programming c++

Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Mohamed El Desouki
 
Logic Formulation 1
Logic Formulation 1Logic Formulation 1
Logic Formulation 1deathful
 
chapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfchapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfBernardVelasco1
 
COM1407: Structured Program Development
COM1407: Structured Program Development COM1407: Structured Program Development
COM1407: Structured Program Development Hemantha Kulathilake
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
CIS110 Computer Programming Design Chapter (1)
CIS110 Computer Programming Design Chapter  (1)CIS110 Computer Programming Design Chapter  (1)
CIS110 Computer Programming Design Chapter (1)Dr. Ahmed Al Zaidy
 
CHAPTER-1.ppt
CHAPTER-1.pptCHAPTER-1.ppt
CHAPTER-1.pptTekle12
 
Synapseindia dot net development computer programming
Synapseindia dot net development  computer programmingSynapseindia dot net development  computer programming
Synapseindia dot net development computer programmingSynapseindiappsdevelopment
 
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
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptxshoaibkhan716300
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge imtiazalijoono
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1Mubarek Kurt
 

Semelhante a First draft programming c++ (20)

Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++
 
Logic Formulation 1
Logic Formulation 1Logic Formulation 1
Logic Formulation 1
 
C.pdf
C.pdfC.pdf
C.pdf
 
chapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfchapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdf
 
Chap1
Chap1Chap1
Chap1
 
COM1407: Structured Program Development
COM1407: Structured Program Development COM1407: Structured Program Development
COM1407: Structured Program Development
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
CIS110 Computer Programming Design Chapter (1)
CIS110 Computer Programming Design Chapter  (1)CIS110 Computer Programming Design Chapter  (1)
CIS110 Computer Programming Design Chapter (1)
 
CHAPTER-1.ppt
CHAPTER-1.pptCHAPTER-1.ppt
CHAPTER-1.ppt
 
Synapseindia dot net development computer programming
Synapseindia dot net development  computer programmingSynapseindia dot net development  computer programming
Synapseindia dot net development computer programming
 
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
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptx
 
Week10 final
Week10 finalWeek10 final
Week10 final
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
C programming
C programmingC programming
C programming
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1
 
C session 1.pptx
C session 1.pptxC session 1.pptx
C session 1.pptx
 

Último

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 

Último (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
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🔝
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 

First draft programming c++

  • 1. An Introduction to Programming with C++ Sixth Edition Chapter 1 An Introduction to Programming
  • 2. Objectives • Define the terminology used in programming • Explain the tasks performed by a programmer • Describe the qualities of a good programmer • Understand the employment opportunities for programmers and software engineers • Explain the history of programming languages An Introduction to Programming with C++, Sixth Edition 2
  • 3. Objectives (cont’d.) • Explain the sequence, selection, and repetition structures • Write simple algorithms using the sequence, selection, and repetition structures An Introduction to Programming with C++, Sixth Edition 3
  • 4. Programming a Computer • Programs are the directions given to computers • Programmers are the people who write computer programs • Programming Languages enable programmers to communicate with the computer • Popular languages: C++, Visual Basic, C#, Java • How are these languages used commercially? An Introduction to Programming with C++, Sixth Edition 4
  • 5. The Programmer’s Job • Programmers help solve computer problems • Employee or freelance • Typical steps involved – Meet with user to determine problem – Convert the problem into a program – Test the program – Provide user manual An Introduction to Programming with C++, Sixth Edition 5
  • 6. An Introduction to Programming with C++, Sixth Edition 6 Do I Have What It Takes to Be a Programmer? • Qualities employers look for – Logical and analytical thinking – Close attention to detail – Patience and persistence – Ingenuity and creativity – Good communication skills: technical and nontechnical – Business skills (for managerial positions)
  • 7. Employment Opportunities • Computer software engineer: designs an appropriate solution to a user’s problem • Computer programmer: codes a computer solution • Coding is the process of translating a computer solution into a language a computer can understand • Some positions call for both engineering and programming An Introduction to Programming with C++, Sixth Edition 7
  • 8. A Brief History of Programming Languages • Enable programmer to communicate with computer • Different types – Machine languages – Assembly languages – High-level languages An Introduction to Programming with C++, Sixth Edition 8
  • 9. An Introduction to Programming with C++, Sixth Edition 9 Machine Languages • The first programmers had to write the program instructions using only combinations of 0s and 1s – Example: 00101 10001 10000 • Instructions written in 0s and 1s are called machine language or machine code • Each type of machine has its own language • Machine languages are the only way to communicate directly with the computer • Programming in machine language: tedious and error-prone; requires highly trained programmers
  • 10. An Introduction to Programming with C++, Sixth Edition 10 Assembly Languages • Assembly languages simplify programmer’s job • Can use mnemonics instead of 0s and 1s – Example: ADD bx, ax • Assembly programs require an assembler to convert instructions into machine code • Easier to write programs in assembly language – But still tedious and requires highly trained programmers
  • 11. An Introduction to Programming with C++, Sixth Edition 11 High-Level Languages • High-level languages allow programmer to use English-like instructions – Example: grossPay = hours * rate – High-level languages are more machine independent • Programs written in a high-level language can be used on many different types of computers • Compilers translate high-level instructions into 0s and 1s (machine language) • Interpreters translate the program line by line as the program is running
  • 12. An Introduction to Programming with C++, Sixth Edition 12 High-Level Languages (cont’d.) • When writing a procedure-oriented program, the programmer concentrates on the major tasks that the program needs to perform – Examples: COBOL, BASIC, C • An object-oriented program requires programmer to focus on the objects that the program can use to accomplish its goal – Examples: C++, Visual Basic, Java, C# • Object-oriented programs allow for better code- reuse – An object can be used in more than one program
  • 13. An Introduction to Programming with C++, Sixth Edition 13 Control Structures • Programs are written using three basic structures – Sequence • Used in every program you write – Repetition • Used in most programs you write – Selection • Used in most programs you write • These are called control structures or logic structures
  • 14. An Introduction to Programming with C++, Sixth Edition 14 The Sequence Structure • The sequence structure directs the computer to process the program instructions, one after another, in the order listed in the program • An algorithm is a set of step-by-step instructions that accomplish a task • Example: following a recipe to make cookies
  • 15. The Sequence Structure (cont’d.) An Introduction to Programming with C++, Sixth Edition 15 Figure 1-1 An example of the sequence structure
  • 16. An Introduction to Programming with C++, Sixth Edition 16 The Selection Structure • Selection structure: makes a decision and then takes an appropriate action based on that decision – Also called the decision structure • Example: waiting or crossing at railroad tracks depending on signal lights
  • 17. The Selection Structure (cont’d.) An Introduction to Programming with C++, Sixth Edition 17 Figure 1-2 An example of the selection structure
  • 18. An Introduction to Programming with C++, Sixth Edition 18 The Selection Structure (cont’d.) Figure 1-3 Another example of the selection structure
  • 19. An Introduction to Programming with C++, Sixth Edition 19 The Repetition Structure • Repetition structure: directs computer to repeat one or more instructions until some condition is met – Also called a loop or iteration Figure 1-4 Modified algorithm showing the repetition structure
  • 20. An Introduction to Programming with C++, Sixth Edition 20 The Repetition Structure (cont’d.) • What could you do if you don’t know precisely how many steps separate Robin from the boxes? Figure 1-5 Algorithm showing the modified condition in the repetition structure
  • 21. Summary • Programs are step-by-step instructions that tell a computer how to perform a task • Programmers use programming languages to communicate with the computer – First programming languages were machine languages: 0s and 1s (machine code) – Next came assembly languages, which allowed for mnemonics – High-level languages can be used to create procedure-oriented programs or object-oriented programs An Introduction to Programming with C++, Sixth Edition 21
  • 22. Summary (cont’d.) • Algorithm: step-by-step instructions that accomplish a task (not written in a programming language) – Algorithms contain one or more of the following control structures: sequence, selection, and repetition • Sequence structure: process the instructions, one after another, in the order listed • Selection structure: directs the computer to make a decision and then to select an appropriate action based on that decision • Repetition structure: repeat one or more instructions until some condition is met An Introduction to Programming with C++, Sixth Edition 22
  • 23. YOUR Assignments – Lab 1-1: Stop and Analyze • A local business employs five salespeople and pays a 3% bonus on a salesperson’s sales • Your task is to create a program that calculates the amount of each salesperson’s bonus • The program should print each salesperson’s name and bonus amount An Introduction to Programming with C++, Sixth Edition 23
  • 24. An Introduction to Programming with C++, Sixth Edition 24 YOUR Assignments – Lab 1-2: Plan and Create • Using only the instructions shown below, create an algorithm that shows the steps an instructor takes when grading a test that contains 25 questions
  • 25. An Introduction to Programming with C++, Sixth Edition 25 YOUR Assignments – Lab 1-3: Modify • Modify the algorithm shown in Lab 1-1 so that it gives a 3.5% bonus to salespeople selling more than $2,000 • All other salespeople should receive a 3% bonus
  • 26. Your Assignments - Labs – – Lab 1 – Stop and Analyze – Lab 2 - Plan and Create – Lab 3 – Modify Review Questions – pages 13-15 Chapter 1 – Exercises – Pages 15-19 An Introduction to Programming with C++, Sixth Edition 26