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

Simple OperatorsSimple Operators

The assignment operator (=) is used in programming to assign a value to a variable. The syntax looks as follows:

cpp

main.cpp

It works exactly the same with the string data type:

cpp

main.cpp

The equality (==) and inequality (!=) operators are used to numerically compare 2 variables:

cpp

main.cpp

Why 1 and 0? This is an alternative approach for utilizing the boolean data type. When the expression var == 9 is true, it is represented as 1, and it means that var is indeed equal to the number 9. Conversely, when the expression var == -9 is false, it is represented as 0, indicating that var is not equal to the number -9.

The inequality (!=) operator is doing exactly the opposite:

cpp

main.cpp

Everything was clear?

Section 3. Chapter 1
course content

Course Content

C++ Introduction

Simple OperatorsSimple Operators

The assignment operator (=) is used in programming to assign a value to a variable. The syntax looks as follows:

cpp

main.cpp

It works exactly the same with the string data type:

cpp

main.cpp

The equality (==) and inequality (!=) operators are used to numerically compare 2 variables:

cpp

main.cpp

Why 1 and 0? This is an alternative approach for utilizing the boolean data type. When the expression var == 9 is true, it is represented as 1, and it means that var is indeed equal to the number 9. Conversely, when the expression var == -9 is false, it is represented as 0, indicating that var is not equal to the number -9.

The inequality (!=) operator is doing exactly the opposite:

cpp

main.cpp

Everything was clear?

Section 3. Chapter 1
some-alt