Lecture 1 Next Lecture

Lecture 1, Tue 01/07

Course overview, a gentle intro to C++ - Standard I/O

Topics

Course logistics

Programming in the unix environment

vim Editor

Writing, compiling and running a C++ program (hello world) program

// hello.cpp
#include <iostream>

using namespace std;

int main() {
	cout << "Hello CS 16!" << endl;
	return 0;
}
$ g++ -o hello hello.cpp
$ ./hello
Hello CS 16!
$

Breaking down the Hello World Program

// hello.cpp
#include <iostream>

using namespace std;

int main() {
	cout << "Hello CS 16!" << endl;
	return 0;
}
#include <iostream>
using namespace std;
int main() { ... }
cout << "Hello CS 16!" << endl;
return 0;

Comments

C++ Variables and Types

Initializing, Assigning, and Modifying Variables

int x;      // initialize variable x of type int
int y, z;   // initialize variables x and y in one statement
x = 10;     // assign x to an integer value 10.

int a = 10;   // initialize and assign in one statement
int b = 20, c = 30;

b = 6 + 4;

cout << a << "," << b << "," << c << "," <<
x << "," << y << "," << z << endl;