Lecture overview -- Keyboard shortcut: 'u'  Previous page: Expressions and operators -- Keyboard shortcut: 'p'  Next page: Functions and parameters -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 21 : 29
Notes about C++
From C to C++
Control structures

The control structures in C are well-known - and almost identical - to control structures in other languages in the C family

  • Selection

    • if conditional and if-else

    • switch - with the break issue!

  • Iteration

    • while and do-while

    • for

      • C++: Can declare local variables (of one type) in the initialization part

      • C: This is not possible in ANSI C - C89

  • Ohter control mechanisms in C

    • goto, break, continue

    • Blocks: {...}

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/control-structures/for-c.cA program with a for loop in C.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/control-structures/for-output-cProgram output.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/control-structures/for.ccIllustration of local variables in a for loop in C++.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/control-structures/for-output-cppProgram output.