![Page 1: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/1.jpg)
Course IntroductionCourse Introduction
C++ An Introduction to Computing
![Page 2: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/2.jpg)
PreliminariesPreliminaries
Instructor:Instructor:
Office Hours:Office Hours:
URL:URL:
Text: Text: C++ An Introduction to ComputingC++ An Introduction to Computing, , by Adams, Leestma & Nyhoffby Adams, Leestma & Nyhoff
Labs: Labs: http://cs.calvin.edu/c++/HandsOnC++http://cs.calvin.edu/c++/HandsOnC++
![Page 3: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/3.jpg)
What is Programming?What is Programming?
A sequence of statements that instruct a A sequence of statements that instruct a computer in how to solve a problem is computer in how to solve a problem is called a called a programprogram..
The act of designing, writing and The act of designing, writing and maintaining a program is called maintaining a program is called programmingprogramming..
People who write programs are called People who write programs are called programmersprogrammers..
![Page 4: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/4.jpg)
What kinds of statementsWhat kinds of statementsdo computers do computers understand?understand?
A computer only understands A computer only understands machine language statements.machine language statements.
A machine language statement is a A machine language statement is a sequence of ones and zeros that sequence of ones and zeros that cause the computer to perform a cause the computer to perform a particular action, such as add, particular action, such as add, subtract, multiply, ...subtract, multiply, ...
![Page 5: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/5.jpg)
Machine Language (ML)Machine Language (ML)
ML statements are stored in a computer’s ML statements are stored in a computer’s memory, which is a sequence of memory, which is a sequence of switches. switches.
For convenience of representation, For convenience of representation, an “on” switch is represented by 1, an “on” switch is represented by 1, and an “off” switch is represented by 0.and an “off” switch is represented by 0.
ML thus appears to be binary (base-2):ML thus appears to be binary (base-2):
00101110101101010010111010110101
![Page 6: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/6.jpg)
Early ComputersEarly Computers
... required a programmer to write in ... required a programmer to write in ML...ML...– Easy to make mistakes!Easy to make mistakes!
– Such mistakes are hard to find!Such mistakes are hard to find!
– Not Not portableportable -- only runs on one kind of -- only runs on one kind of machine!machine!
Programming was very difficult! Programming was very difficult!
![Page 7: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/7.jpg)
A Bright IdeaA Bright Idea
Devise a set of abbreviations (mnemonics) Devise a set of abbreviations (mnemonics) corresponding to the ML statements, plus corresponding to the ML statements, plus a program to translate them into ML.a program to translate them into ML.
The abbreviations are an The abbreviations are an assembly assembly languagelanguage, and the program is called an , and the program is called an assemblerassembler..
Assembler 0010111010110101ADD
![Page 8: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/8.jpg)
Assembly LanguagesAssembly Languages
Allowed a programmer to use Allowed a programmer to use mnemonics, which were more mnemonics, which were more natural than binary.natural than binary.+Much easier to read programsMuch easier to read programs
+Much easier to find and fix mistakesMuch easier to find and fix mistakes
– Still not portable to different machinesStill not portable to different machines
![Page 9: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/9.jpg)
High Level LanguagesHigh Level Languages
Devise a set of statements that are Devise a set of statements that are close to human language (if, while, close to human language (if, while, do, ...), plus a program to do, ...), plus a program to translate them into ML.translate them into ML.
The set of statements is called a The set of statements is called a high high level languagelevel language (HLL) and the (HLL) and the program is called a program is called a compilercompiler..
![Page 10: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/10.jpg)
HLL CompilersHLL Compilers
Where an assembler translates one Where an assembler translates one mnemonic into one ML statement, mnemonic into one ML statement, a HLL compiler translates one HLL a HLL compiler translates one HLL statement into multiple ML statements.statement into multiple ML statements.
Compiler
1010110011110101
0000000000010000
0010111010110101
0000000000010010
0010111011111101
0000000000010100
z = x + y;
![Page 11: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/11.jpg)
HLLsHLLs
High level languages (like C++) areHigh level languages (like C++) are+Much easier to read programsMuch easier to read programs
+Much easier to find and fix mistakesMuch easier to find and fix mistakes
+Portable from one machine to another Portable from one machine to another (so long as they keep to the language (so long as they keep to the language standard).standard).
![Page 12: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/12.jpg)
Objectives in Objectives in ProgrammingProgramming
A program should solve a problem:A program should solve a problem:+correctlycorrectly (it actually solves the problem) (it actually solves the problem)
+efficientlyefficiently (without wasting time or space) (without wasting time or space)
+readablyreadably (understandable by another (understandable by another person)person)
+in a in a user-friendlyuser-friendly fashion fashion (in a way that is easy for its user to use).(in a way that is easy for its user to use).
![Page 13: Course Introduction C++ An Introduction to Computing](https://reader035.vdocuments.us/reader035/viewer/2022072011/56649e0c5503460f94af5a8d/html5/thumbnails/13.jpg)
SummarySummary
There are “levels” to computer There are “levels” to computer languages:languages:
– ML consists of “low” level binary ML consists of “low” level binary statements, that is hard to read, write, statements, that is hard to read, write, and not portable.and not portable.
– Assembly uses “medium” level Assembly uses “medium” level mnemonics: easier to read/write, but not mnemonics: easier to read/write, but not portable.portable.
– C++ is a “high” level language that is C++ is a “high” level language that is even easier to read/write, even easier to read/write, andand portable. portable.