Search Header Logo
C++ Operators

C++ Operators

Assessment

Presentation

Computers

9th - 12th Grade

Medium

Created by

Michael Ask

Used 12+ times

FREE Resource

6 Slides • 4 Questions

1

C++ Operators

by Michael Ask

2

​Operators

​Operators allow you to perform mathematical operations in C++. Like this...

3 + 3;

x / 2;

(x + y) / 2;​

​Notice the use of addition and division.

3

Multiple Select

What other operations do you guess C++ allows?

1

Multiplication

2

Exponents

3

Subtraction

4

​Operators

​Mathematical operations aren't ALWAYS used in code. Just most of the time. So it's important to understand how they work. In this code, the computer will make three variables. The third is the sum of the first two.

​int x = 3;

​int y = 4;

​int z = x + y;

5

​Operators and Output

​While C++ performs any operation that you ask it to, it will only print it for you to see if you request it. This code...

​3 + 3;

​... will work, but it will give you an error telling you that you didn't use the expression. IF you wish to see the result, you must output it. Like this...

​cout << 3+3;

6

Multiple Choice

Mark wants to know what 40 - 32 is, so he types it in like this...

cout << 40 + 32;

Will it work?

1

No

2

Yes

7

Multiple Choice

To print the sum of 45 and 76, what should you type?

1

cout << 45 + 76;

2

cout >> 45 + 76;

3

45 + 76;

4

45 - 76;

8

​Limitations

​Operators can only work in certain situations. For instance, you CANNOT add a number to a string. What would that even mean?

​"Mr Ask" + 97;

​This will throw an error because they are an incompatible pair of data. But C++ is even more picky. This code also does not work.

​"Mr " + "Ask"

9

Multiple Choice

What would be the output of this code?

cout << 10 / 2;

1

5

2

8

3

20

10

​Kinds of Operators

media

C++ Operators

by Michael Ask

Show answer

Auto Play

Slide 1 / 10

SLIDE