Review of C++ Fundamentals Appendix A Language Basics (A2) A2 Comments // This is a single line comment /* * Programmer: Joe Sweeney * Program Name: * Date: * Description: */ A3 Identifiers and Keywords A3 Fundamental Data Types A4 Variables A5 Named Constants A6 Enumerations Named Memory location for storing data A5 Literal Constants string sFirstName = "Joe"; d = double l = long f = float i = int b = boolean c = char s = string A7 The typedef Statement typedef string char[30]; A7 Assignments and Expressions sFirstName = "Joe"; iNumber = 5 + 7 * - mult / - div + - addition - - sub % - modulus &, && - AND |, || - OR ! - NOT 7 != 5 !bDone ++ -- iNumber += 2 iNumber = iNumber + 2 Input and Output Using iostream (A11) #include A11 Input Standard input is keyboard cin >> iNumber; A13 Output Standard output is monitor cout << "Please enter a number: "; Functions (A15) A15 User Defined Functions void main() { } int main(int i) { } A18 Standard Functions Selection Statements (A19) A19 The if Statement if ( condition ) { x = 5; D = 6; } else x = 7; A20 The switch Statement switch ( value ) { case 1: line of code break; case 2: line of code break; case 3: line of code break; default: line of code } Iteration Statements (A21) A21 The while Statement pre-test loop while ( x!=5 ) { x = 5; } A24 The do Statement post-test loop do { } while ( condition ) A22 The for Statement for ( int i=0; i<10; i+=2 ) { x += i; } Strings (A30) A31 C++ Strings #include Array of characters length() and size() comparing substr(position, length) A32 C Strings #include must be null terminated helpful to create typdef copy: strcpy compare: strcmp concatenate: strcat Structures (A35) struct student { string name; int age; double gpa; }; student cis246; cis246.name = "joe"; cis246.age = 41; cis246.gpa = 0;