0% found this document useful (0 votes)
29 views

CP2 Module 3 - Operators in C++

The document discusses different types of operators in C++ including arithmetic, assignment, comparison, and logical operators. It provides examples of how each operator is used in C++ code and the purpose of each type of operator. The learning outcomes are to explain how operators are used in C++, differentiate between operator types, and create programs using different operators.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

CP2 Module 3 - Operators in C++

The document discusses different types of operators in C++ including arithmetic, assignment, comparison, and logical operators. It provides examples of how each operator is used in C++ code and the purpose of each type of operator. The learning outcomes are to explain how operators are used in C++, differentiate between operator types, and create programs using different operators.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

COMPUTER PROGRAMMING 2

Building Expression in C++


PRESENTED BY:
Jhaun Paul G. Enriquez
SHS ICT Faculty
1
LEARNING OUTCOMES:

1. Explain how different operators are used in C++.


2. Differentiate the types of C++ operators.
3. Create C++ programs using different operators.

COMPUTER PRORAMMING 2 2
What is a C++ Operator?
• are used to perform operations on variables and values
• use the + operator to add together values

• It can also be used to add the values of the variable

COMPUTER PROGRAMMING 2 3
What are the types C++ Operators?
• Arithmetic – perform common mathematical operations
• Assignment – used to assign values to variables.
• Comparison - used to compare two values (true or false).
• Logical – used to determine the logic between variables or
values (and, or, not)

COMPUTER PROGRAMMING 2 4
Arithmetic Operators:
- perform common mathematical operations

COMPUTER PROGRAMMING 2 5
Source: https://www.w3schools.com/cpp/cpp_operators.asp
Arithmetic Operators:
- sample code in C++

COMPUTER PROGRAMMING 2 6
Source: https://www.w3schools.com/cpp/cpp_operators.asp
Assignment Operators:
- used to assign values to variables.

COMPUTER PROGRAMMING 2 7
Source:
https://www.w3schools.com/cpp/cpp_operators_assignment.asp
Assignment Operators:

COMPUTER PROGRAMMING 2 8
Source:
https://www.w3schools.com/cpp/cpp_operators_assignment.asp
Comparison Operators:
- The return value of a comparison is either true (1) or false (0)

COMPUTER PROGRAMMING 2 9
Source: https://www.w3schools.com/cpp/cpp_operators_comparison.asp
Comparison Operators:

COMPUTER PROGRAMMING 2 10
Source: https://www.w3schools.com/cpp/cpp_operators_comparison.asp
Logical Operators:
- used to determine the logic between variables or values:

COMPUTER PROGRAMMING 2 11
Source: https://www.w3schools.com/cpp/cpp_operators_logical.asp
Logical "AND" and "OR" Operators:

COMPUTER PROGRAMMING 2 12
Source: https://www.w3schools.com/cpp/cpp_operators_logical.asp
Logical "NOT" Operators:

COMPUTER PROGRAMMING 2 13
Source: https://www.w3schools.com/cpp/cpp_operators_logical.asp
Logical Operators:

COMPUTER PROGRAMMING 2 14
Source: https://www.w3schools.com/cpp/cpp_operators_logical.asp
References:
• Pomperada, Jake. 2019. Beginner’s Guide to C++ Programming.
Manila: Mindshapers Co., Inc.
• Pepito, Copernicus. 2009. Introduction to C++ 2008 programming.
Manila: National Bookstore.
• https://www.codecademy.com/courses/learn-c-plus-plus
• https://www.w3schools.com/cpp/default.asp
• https://www.tutorialspoint.com/cplusplus/index.htm

COMPUTER PROGRAMMING 2 15
COMPUTER PROGRAMMING 2 16
COMPUTER PRORAMMING 2

You might also like