⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽

Arithmetic and Unary Operations

Computer Programming C++ / Getting Started

Operators are the foundation of any programming language. They are symbols that helps us to perform specific mathematical and logical computations.

There are seven classifications of operators in C++. They are:

  • Logical (&&, ||, !)
  • Relational (==, !=, <, >, <=, >=)
  • Arithmetic (+, -, *, /, %)
  • Assignment (=, +=, -=, *=, /=, %=)
  • Unary (++, --)
  • Bitwise (&, |, <<, >>, ~, ^)
  • Ternary (?:)

Some of these you probably already know. Others you will be required to learn in this class, and others yet will not be required. The following video will review the arithmetic operators, then cover the assignment (and unary) operators.

You are not required to know about the bitwise and ternary operators. However, if you want to, you can click here to learn about bitwise operators.

I also cover the ternary operator in the "Above and Beyond" section of the next page.

Occasionally while looking at code, you'll see the unary operators used in an odd way. This video explains what's happening.

Review Questions

The following are examples of questions similar to what you can expect to see on the next exam.

Hover over a question to show the answer.

Consider the following code:

int i = 7;
i++;
i /= 2;
i--;
std::cout << "The value of i is: " << i;
  1. What would print to the console? The value of i is: 3
⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel