CSCI261C/E
Lecture 3: C++ Fundamentals (continued) August 31, 2011
CSCI261C/E Lecture 3: C++ Fundamentals (continued) August 31, 2011 - - PowerPoint PPT Presentation
CSCI261C/E Lecture 3: C++ Fundamentals (continued) August 31, 2011 ? Alan Turing 1912 - 1954 Turing Machine aka Universal Machine the man himself bombe code-breaking machine Review C++ program structure Preprocessing
Lecture 3: C++ Fundamentals (continued) August 31, 2011
1912 - 1954 “Turing Machine” aka “Universal Machine”
bombe code-breaking machine
the man himself
// a one line comment /* a multi- line comment */ /* omg! */
...is like a period at the end of a sentence. EXCEPT for preprocessing directives (they are special) #include<somelibrary>
dude, no semicolon!
double Porsche; double porsche; double pOrScHe; These are three different variables!
[this is optional]
[modifier] type name [= initial value]; [modifier] type name [(initial value)]; int x; int q = 0; double height(23.0); const int DAYS = 7; double z, y(0); // two at once, for style char initial = ‘j’; // character values need single-quotes
const (for now)
const double PI = 3.14159;
int x; x = 1; x++; x = x + 1;
int x, y; x = 10; y = ++x - 3; x = x + 1; y = x - 3; int x, y; x = 10; y = x++ - 3; y = x - 3; x = x + 1;
int age = 21; double grade = 4.0; age = 21.5; // age = 21 grade = 2; // grade = 2.0 grade = ‘a’; // grade = ?*
* the ascii numeric value for the lower case letter ‘a’
#include<cmath> Gives you the power of... fabs(x) sqrt(x) pow(x,y) log(x) and more!
const double PI = acos(-1.0); Are like “mini programs” your program can use Are abstractions Take input (usually) Return a value (usually)