C++

Card Set Information

Author:
rrwick
ID:
128834
Filename:
C++
Updated:
2012-01-18 21:56:06
Tags:

Folders:

Description:
My C++ cards
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user rrwick on FreezingBlue Flashcards. What would you like to do?


  1. For loop syntax
    for(initialiser; condition; iteration){statements}

    Any of the three items in parentheses can be left out.
  2. While loop syntax
    while(condition){statements}
  3. Do-while loop syntax
    do{statements}while(condition);

    Unlike the while loop, this will always execute the statements at least once.

    Don't forget the semicolon at the end.
  4. Switch-case syntax
    • switch(value){
    • case target_value: statements
    • case target_value: statements
    • case target_value: statements
    • default: statements
    • }

    Each group of statements should end with "break;". Otherwise, all the code following will be executed.

    • Default is optional, it functions like an "else" would.

    Example:

    • switch(x){
    • case 1: cout << "one"; break;
    • case 2: cout << "two"; break;
    • case 3: cout << "three"; break;
    • }
  5. If else syntax
    • if (condition){statements}
    • if else (condition){statements}
    • else (condition){statements}

    The "if else" and "else" parts are optional. You can have as many "if else" parts as needed.

What would you like to do?

Home > Flashcards > Print Preview