CSC 2.2 S2

Cards (28)

  • Operators in C++ can be classified into 6 types: 1. Arithmetic Operators 2. Assignment Operators 3. Relational Operators 4. Logical Operators 5. Compound Operators 6. Increment & Decrement Operators
  • Operator : +
    Operation : addition
  • Operator : - Operation : substraction
  • Operator : * Operation : multiplication
  • Operator : / Operation : division
  • Operator : % Operation : Modula operation
  • Operator : a = b; Equivalent to : a=b;
  • Operator : a += b; Equivalent to : a = a + b;
  • Operator : a -= b; Equivalent to : a = a - b;
  • Operator : a *= b; Equivalent to : a = a * b;
  • Operator : a /= b; Equivalent to : a = a / b;
  • Operator : a %= b; Equivalent to : a = a % b;
  • Operator : ==
    Meaning : equal to
    Example 3 == 5 is 0
  • Operator : !=
    Meaning : not equal to
    Example : 3 != 5 is 1
  • Operator : > Meaning : greater than Example : 3 > 5 is 0
  • Operator : < Meaning : less than Example : 3 < 5 is 1
  • Operator : >= Meaning : greater than or equal to Example : 3 >= 5 is 0
  • Operator : <= Meaning : less than or equal to Example : 3 <= 5 is 1
  • Operator : && Meaning : true if all the operands are true
    Example : expression 1 && expression 2 is 1
  • Operator : || Meaning : true if at least one operands is true
    Example : expression 1 || expression 2 is 0
  • Operator : ! Meaning : true if only operands is false
    Example : !expression is 1
  • Operator : price *= units + 1
    Equivalent : price = price * (units+1)
  • Every statement must end with semicolon ( ; )
    Terminate with return 0;
  • 0 is false
    1 is true
  • Arithmetic Operators
    1. Addition , +
    2. Substraction, -
    3. Multiplication, *
    4. Division, /
    5. Modula Operation, %
  • Assignment Operators
    1. a = b;
    2. a += b; additional
    3. a -= b; substraction
    4. a *= b; multiplication
    5. a /= b; division
    6. a %= b; Modula operation
  • Relational Operators
    1. Equal to, ==
    2. Not equal to, !=
    3. Greater than, >
    4. Less than, <
    5. Greater than or Equal to, >=
    6. Less than or Equal to, <=
  • Logical operators
    1. Logical AND, &&
    2. Logical OR, ||
    3. Logical NOT, !