Assignment 1 due Thursday 12:00 midnightSign up for the class mailing list. Project 2 will be assigned using that!
Project 1 assigned tomorrow:
Hint: Practive writing simple programs, output and mathematic operations.
Variable Types (re-visited)
What is a variable?
CS151 -- Shawn Stoffer
Variable Types (re-visited)
How is a variable represented in the computer?
Variable Types (re-visited)
What is so important about variables anyway?
Running Programs
CS151 -- Shawn Stoffer
Running Programs
Running Programs
x = 3*4+5;
mov 3, r1
mul r3, 4, r1
add r3, 5, r3
st r3, [@x]
11110000010100100000001100000001
01101000010101100000010000000001
10101000010101100000011100000011
11111111010101100000000000011011
Running Programs
Running Programs
Programming
Programming
Programming
Programming
Programming
C++ History
- Kernigan and Ritchie
- AT&T Bell Labs
- B
- C
- C++
- Why?
C++
Simple program:<one or more includes>
using namespace std;int main() {
<one or more statements>
return 0;
}
C++
Simple program (filled out):#include <iostream>
using namespace std;int main() {
cout << "Good morning, Dave." << endl;
return 0;
}
C++
Simple program (filled out):#include <iostream>
using namespace std;
- #include <iostream> is necessary for the use of the cout variable, and the << operator.
- using namespace std; is necessary to access the definitions inside the included iostream.
C++
Simple program (filled out):int main() {
- int main() is the first, and only function that you will use now.
- Operating System calls main() to execute your program, when you execute your program from the command line.
- { is there to start the function definition of main, this tells the compiler that you are starting a block, and to, whenever main is called, execute everything between this ({) and the ending brace, (})
C++
Simple program (filled out):cout << "Good morning, Dave." << endl;
- cout says that you want to send the output to the standard output, for now this is the only one that you will use
- << says that you want to 'put' something in cout
- "Good morning, Dave." is what you want to put into cout
- << -- you want to put something else in cout.
- endl -- put and endline into cout
C++
Simple program (filled out):return 0;
}
- return 0; says that you want to end the program, and if anyone is watching, then it should send 0 back to them.
- } ends the function main.
C++
reading a program:
- cout << "Good morning, Dave." << endl;
- put, into cout, the string (") Good morning, Dave (") and then put an endline into cout as well.
- Why not: cout << "Good morning, Dave." endl;
- Because, "Good morning, Dave" is one thing and endl is another, therefore since you can only 'put' one thing into cout at a time, it causes an error.