SlideShare a Scribd company logo
1 of 12
C++ Programming: From Problem
Analysis to Program Design,

Fifth Edition

Chapter 1: An Overview of Computers and
Programming Languages

Updated by: SENG Sourng
The Evolution of Programming
Languages (cont'd.)


High-level languages include Basic,
FORTRAN, COBOL, Pascal, C, C++, C#, and
Java



Compiler: translates a program written in a
high-level language machine language

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

2
Processing a C++ Program
#include <iostream>
using namespace std;
int main()
{
cout << "My first C++ program." << endl;
return 0;
}

Sample Run:
My first C++ program.

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

3
Processing a C++ Program (cont'd.)


To execute a C++ program:





Use an editor to create a source program in C++
Preprocessor directives begin with # and are
processed by a the preprocessor
Use the compiler to:



Check that the program obeys the rules
Translate into machine language (object program)

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

4
Processing a C++ Program (cont'd.)


To execute a C++ program (cont'd.):


Linker:


Combines object program with other programs provided
by the SDK to create executable code



Loader:




Loads executable program into main memory

The last step is to execute the program

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

5
Processing a C++ Program (cont'd.)

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

6
Programming with the Problem Analysis–Coding–
Execution Cycle


Programming is a process of problem solving



One problem-solving technique:



Outline the problem requirements





Analyze the problem

Design steps (algorithm) to solve the problem

Algorithm:


Step-by-step problem-solving process



Solution achieved in finite amount of time

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

7
The Problem Analysis–Coding–Execution Cycle
(cont’d.)

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

8
The Problem Analysis–Coding–Execution Cycle
(cont'd.)



Run code through compiler
If compiler generates errors





If there are no syntax errors




Look at code and remove errors
Run code again through compiler
Compiler generates equivalent machine code

Linker links machine code with system
resources

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

9
The Problem Analysis–Coding–Execution Cycle
(cont'd.)





Once compiled and linked, loader can place
program into main memory for execution
The final step is to execute the program
Compiler guarantees that the program follows
the rules of the language


Does not guarantee that the program will run
correctly

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

10
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

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

11
Example 1-1 (cont'd.)


Algorithm:


Get length of the rectangle



Get width of the rectangle



Find the perimeter using the following equation:
perimeter = 2 * (length + width)



Find the area using the following equation:
area = length * width

C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Updated by: SENG Sourng

12

More Related Content

What's hot

SeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression testsSeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression testsOliver Libutzki
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionalsphanleson
 
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...Technical Agility institute
 
How to Slay a Battery of Tests
How to Slay a Battery of TestsHow to Slay a Battery of Tests
How to Slay a Battery of TestsThoughtworks
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemoachipa
 
How to slay a battery of tests
How to slay a battery of testsHow to slay a battery of tests
How to slay a battery of testsApoorva M
 
Compiler interpreter and_bootstrapping
Compiler interpreter and_bootstrappingCompiler interpreter and_bootstrapping
Compiler interpreter and_bootstrappingsandeep manzhi
 
Static analysis of C++Builder and WinRT projects
Static analysis of C++Builder and WinRT projectsStatic analysis of C++Builder and WinRT projects
Static analysis of C++Builder and WinRT projectsPVS-Studio
 
Никита Манько “Code review”
Никита Манько “Code review”Никита Манько “Code review”
Никита Манько “Code review”EPAM Systems
 
Building Eclipse Plugins and RCP applications with Tycho
Building Eclipse Plugins and RCP applications with TychoBuilding Eclipse Plugins and RCP applications with Tycho
Building Eclipse Plugins and RCP applications with Tychojsievers
 
Composing Music in the Cloud
Composing Music in the CloudComposing Music in the Cloud
Composing Music in the CloudCodemotion
 
Whats resources compat_contextcompat_and_appcompat
Whats resources compat_contextcompat_and_appcompatWhats resources compat_contextcompat_and_appcompat
Whats resources compat_contextcompat_and_appcompatChang John
 
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and FilesPython Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and FilesP3 InfoTech Solutions Pvt. Ltd.
 
Novedades en C# 10, .NET 6 y ASP.NET 6
Novedades en C# 10, .NET 6 y ASP.NET 6Novedades en C# 10, .NET 6 y ASP.NET 6
Novedades en C# 10, .NET 6 y ASP.NET 6Darío Kondratiuk
 
1 Introduction to Computers and Programming Language
1 Introduction to Computers and Programming Language1 Introduction to Computers and Programming Language
1 Introduction to Computers and Programming LanguageKwan Lee
 

What's hot (20)

SeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression testsSeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression tests
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
 
How to Slay a Battery of Tests
How to Slay a Battery of TestsHow to Slay a Battery of Tests
How to Slay a Battery of Tests
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemo
 
How to slay a battery of tests
How to slay a battery of testsHow to slay a battery of tests
How to slay a battery of tests
 
Benefits of Extensions
Benefits of ExtensionsBenefits of Extensions
Benefits of Extensions
 
Concource CI/CD
Concource CI/CDConcource CI/CD
Concource CI/CD
 
Lab3 s2
Lab3 s2Lab3 s2
Lab3 s2
 
Compiler interpreter and_bootstrapping
Compiler interpreter and_bootstrappingCompiler interpreter and_bootstrapping
Compiler interpreter and_bootstrapping
 
Static analysis of C++Builder and WinRT projects
Static analysis of C++Builder and WinRT projectsStatic analysis of C++Builder and WinRT projects
Static analysis of C++Builder and WinRT projects
 
Никита Манько “Code review”
Никита Манько “Code review”Никита Манько “Code review”
Никита Манько “Code review”
 
Abhishek_Resume
Abhishek_ResumeAbhishek_Resume
Abhishek_Resume
 
Building Eclipse Plugins and RCP applications with Tycho
Building Eclipse Plugins and RCP applications with TychoBuilding Eclipse Plugins and RCP applications with Tycho
Building Eclipse Plugins and RCP applications with Tycho
 
Composing Music in the Cloud
Composing Music in the CloudComposing Music in the Cloud
Composing Music in the Cloud
 
Whats resources compat_contextcompat_and_appcompat
Whats resources compat_contextcompat_and_appcompatWhats resources compat_contextcompat_and_appcompat
Whats resources compat_contextcompat_and_appcompat
 
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and FilesPython Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and Files
 
Novedades en C# 10, .NET 6 y ASP.NET 6
Novedades en C# 10, .NET 6 y ASP.NET 6Novedades en C# 10, .NET 6 y ASP.NET 6
Novedades en C# 10, .NET 6 y ASP.NET 6
 
1 Introduction to Computers and Programming Language
1 Introduction to Computers and Programming Language1 Introduction to Computers and Programming Language
1 Introduction to Computers and Programming Language
 
Kalyani_3+wlan_resume(1)
Kalyani_3+wlan_resume(1)Kalyani_3+wlan_resume(1)
Kalyani_3+wlan_resume(1)
 

Similar to C++ Programming Chapter 01

Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01Terry Yoast
 
An introduction to programming
An introduction to programmingAn introduction to programming
An introduction to programmingrprajat007
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chaptersIbrahim Elewah
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...bhargavi804095
 
Csc1100 lecture01 ch01 pt2-paradigm (1)
Csc1100 lecture01 ch01 pt2-paradigm (1)Csc1100 lecture01 ch01 pt2-paradigm (1)
Csc1100 lecture01 ch01 pt2-paradigm (1)IIUM
 
Csc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmCsc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmIIUM
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...bhargavi804095
 

Similar to C++ Programming Chapter 01 (20)

C++ ch1
C++ ch1C++ ch1
C++ ch1
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
An introduction to programming
An introduction to programmingAn introduction to programming
An introduction to programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
C in7-days
C in7-daysC in7-days
C in7-days
 
C in7-days
C in7-daysC in7-days
C in7-days
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chapters
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 
Csc1100 lecture01 ch01 pt2-paradigm (1)
Csc1100 lecture01 ch01 pt2-paradigm (1)Csc1100 lecture01 ch01 pt2-paradigm (1)
Csc1100 lecture01 ch01 pt2-paradigm (1)
 
Csc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmCsc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigm
 
Week10 final
Week10 finalWeek10 final
Week10 final
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
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
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
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...
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
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 ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
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
 
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
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

C++ Programming Chapter 01

  • 1. C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: SENG Sourng
  • 2. The Evolution of Programming Languages (cont'd.)  High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java  Compiler: translates a program written in a high-level language machine language C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 2
  • 3. Processing a C++ Program #include <iostream> using namespace std; int main() { cout << "My first C++ program." << endl; return 0; } Sample Run: My first C++ program. C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 3
  • 4. Processing a C++ Program (cont'd.)  To execute a C++ program:    Use an editor to create a source program in C++ Preprocessor directives begin with # and are processed by a the preprocessor Use the compiler to:   Check that the program obeys the rules Translate into machine language (object program) C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 4
  • 5. Processing a C++ Program (cont'd.)  To execute a C++ program (cont'd.):  Linker:  Combines object program with other programs provided by the SDK to create executable code  Loader:   Loads executable program into main memory The last step is to execute the program C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 5
  • 6. Processing a C++ Program (cont'd.) C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 6
  • 7. Programming with the Problem Analysis–Coding– Execution Cycle  Programming is a process of problem solving  One problem-solving technique:   Outline the problem requirements   Analyze the problem Design steps (algorithm) to solve the problem Algorithm:  Step-by-step problem-solving process  Solution achieved in finite amount of time C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 7
  • 8. The Problem Analysis–Coding–Execution Cycle (cont’d.) C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 8
  • 9. The Problem Analysis–Coding–Execution Cycle (cont'd.)   Run code through compiler If compiler generates errors    If there are no syntax errors   Look at code and remove errors Run code again through compiler Compiler generates equivalent machine code Linker links machine code with system resources C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 9
  • 10. The Problem Analysis–Coding–Execution Cycle (cont'd.)    Once compiled and linked, loader can place program into main memory for execution The final step is to execute the program Compiler guarantees that the program follows the rules of the language  Does not guarantee that the program will run correctly C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 10
  • 11. 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 C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 11
  • 12. Example 1-1 (cont'd.)  Algorithm:  Get length of the rectangle  Get width of the rectangle  Find the perimeter using the following equation: perimeter = 2 * (length + width)  Find the area using the following equation: area = length * width C++ Programming: From Problem Analysis to Program Design, Fifth Edition Updated by: SENG Sourng 12