Previous Lecture lect02 Slides Next Lecture

Code from lecture

https://github.com/ucsb-cs16-f18-mirza/cs16-f18-lectures/tree/master/lec-02

Topics

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;

Code anywhere and everywhere with git

What is git?

Why are we learning git in this class?

Git concepts