
C++ Operators
Presentation
•
Computers
•
9th - 12th Grade
•
Medium
Michael Ask
Used 14+ 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?
Multiplication
Exponents
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?
No
Yes
7
Multiple Choice
To print the sum of 45 and 76, what should you type?
cout << 45 + 76;
cout >> 45 + 76;
45 + 76;
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;
5
8
20
10
Kinds of Operators
C++ Operators
by Michael Ask
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
8 questions
H CS - Environmental impact (revision)
Presentation
•
9th - 12th Grade
8 questions
расшифровка анаграмм
Presentation
•
9th - 12th Grade
10 questions
Grammar 4A - ir + a + infinitive
Presentation
•
9th - 12th Grade
3 questions
8) Protecting Data Part 1
Presentation
•
9th - 12th Grade
7 questions
1.1 Getting to Know Excel
Presentation
•
9th - 12th Grade
7 questions
JavaScript Function Review
Presentation
•
9th - 12th Grade
7 questions
03.02 Browser
Presentation
•
9th - 12th Grade
7 questions
Pelatihan FPD
Presentation
•
KG
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade