CFE2 - ch01 - Final (KT14303)
CFE2 - ch01 - Final (KT14303)
CFE2 - ch01 - Final (KT14303)
Hardware
The physical computer and peripheral devices are
collectively called the hardware.
Software
The programs the computer executes are called
the software.
Programming
is the act of designing and
implementing computer programs.
• The CPU
– carries out arithmetic operations such as addition,
subtraction, multiplication, and division
– fetches data from external memory or devices and
stores data back.
• All data must travel through the CPU whenever it is
moved from one location to another.
squeak?
This process
reflects the way
programmers work
(shown as a flowchart)
and
you MUST know:
And, finally…
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl;
8 return 0;
9 }
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl;
8 return 0;
9 }
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl;
8 return 0;
9 }
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl;
8 return 0;
9 }
• You can display more than one thing by re-using the <<
operator: << "Hello, World!" << endl;
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl;
8 return 0;
9 }
ch01/hello.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl ;
8 return 0 ;
9 }
ARGH!!!!
Common error
Oh No!
Omitting a semicolon (or two)
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 cout << "Hello, World!" << endl
8 return 0;
9 }
• The compiler will not stop compiling, and will most likely
list lots and lots of errors that are caused by the first one
it encountered.
• You should fix only those error messages that make
sense to you, starting with the first one, and then
recompile (after SAVING, of course!).
C++
Consider this:
really an error!
cout << 1 / 0;
C++
– is case sensitive. Typing:
int Main()
No!
An algorithm is a
RECIPE
Pseudocode
• An informal description
• Not in a language that a computer can understand, but
easily translated into a high-level language (like C++).
What is the
algorithm?
Now we’re
cookin’ with
algorithms!