Sunday, March 12, 2017

C++ Part 13


Types of Control

  • Selection: Execute a different instruction depending on the result of evaluating some [Boolean] condition.
    • if/else, multiway if, switch, ? :
  • Iteration: Repetitively execute some instruction until some condition is met.
    •  for, while, do while.

Conditions

A condition is a Boolean expression - i.e., one that evaluates to true or false.
Most commonly either a relational operator or a logical combination of conditions:
Relational (Comparison) Operators:
== != < > <= >=
Logical operators:
! && ||
For example :  
  • n <= 100 && n >= 0  // n less than equal to AND n must be greater than 0
  • n< 101 && n >= 0  // n less than 101 AND n greater than equal to 0
  • grade> ’c’ && grade <= ’f’ // grade greater than 'c' ( character c ) AND less than equal to 'f'
  • y< x && y >= 0   // 

No comments:

Digital Design Part 3

4th→ assembler translates it to the machine language. 1.6 [20] <§1.6> Consider two diļ¬€erent implementations of the same instru...