Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Operators Introduction | Introduction to Operators
C++ Introduction
course content

Course Content

C++ Introduction

C++ Introduction

1. Getting Started
2. Introduction to Operators
3. Variables and Data Types
4. Introduction to Program Flow
5. Introduction to Functions

book
Operators Introduction

Operators are symbols or keywords in programming that perform operations on variables or values. They are the building blocks for performing tasks like arithmetic, comparisons, logical decisions, and more.

Arithmetic
Relational
Logical
Increment/Decrement
+, -, *, /, %
==, !=, <, >, <=, >=
&&, ||, &, |
++, --

Arithmetic operators are the most basic ones; they include well-known signs like addition (+), multiplication (*), subtraction (-), division (/), and modulo (%) for calculating the remainder of a division.

cpp

main

copy
123456789101112
#include <iostream> int main() { // `std::endl` moves each `std::cout` output to a new line // You can try removing `std::endl` to see the result std::cout << 5 + 5 << std::endl; std::cout << 5 - 5 << std::endl; std::cout << 5 / 5 << std::endl; std::cout << 5 * 5 << std::endl; std::cout << 5 % 5 << std::endl; }

Each operator has its unique function, and all of them can be divided into categories: unary, binary, and ternary. Arithmetic operators are binary because they require two operands to achieve a result.

cpp

main

copy
123456789
#include <iostream> int main() { // 5 (first operand) // - (operation) // 3 (second operand) std::cout << 5 - 3 << std::endl; }

Removing an operand from an operator that requires it will result in an error, as the program expects the correct number of operands to perform the operation.

Unary operators, such as decrement and increment, require only one operand, while ternary operators need three. We will explore each category of operators from the beginning, learning how they work and what they require.

1. What are operators in programming?
2. What does a binary operator require?
3. What happens if you use an operator without the correct number of operands?
What are operators in programming?

What are operators in programming?

Select the correct answer

What does a binary operator require?

What does a binary operator require?

Select the correct answer

What happens if you use an operator without the correct number of operands?

What happens if you use an operator without the correct number of operands?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 1
We're sorry to hear that something went wrong. What happened?
some-alt