0% found this document useful (0 votes)
17 views13 pages

CP2 Module 6 - Operators and Strings

The document discusses operators and strings in C++. It explains that operators are used to perform operations on variables and values, and there are four main types: arithmetic, assignment, comparison, and logical. Arithmetic operators perform math operations, assignment operators assign values, comparison operators return true or false, and logical operators determine logic using AND, OR, and NOT. It also discusses strings, explaining they are used for text and can be concatenated using the + operator or append() function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views13 pages

CP2 Module 6 - Operators and Strings

The document discusses operators and strings in C++. It explains that operators are used to perform operations on variables and values, and there are four main types: arithmetic, assignment, comparison, and logical. Arithmetic operators perform math operations, assignment operators assign values, comparison operators return true or false, and logical operators determine logic using AND, OR, and NOT. It also discusses strings, explaining they are used for text and can be concatenated using the + operator or append() function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

COMPUTER PROGRAMMING 2

Operations and Strings


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

1. Explain how operators and strings are used in C++.


2. Differentiate the types of C++ operators.
3. Create a C++ program 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

Source: https://www.w3schools.com/cpp/cpp_operators.asp

COMPUTER PROGRAMMING 2 5
Assignment Operators:

COMPUTER PROGRAMMING 2 6
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 7
Source: https://www.w3schools.com/cpp/cpp_operators_assignment.asp
Logical Operators:

AND OR NOT

TT = T TT = T TT = F
TF = F TF = T TF = F
FT = F FT = T FT = F
FF = F FF = F FF = T

COMPUTER PROGRAMMING 2 8
Source: https://www.w3schools.com/cpp/cpp_operators_assignment.asp
What are Strings?
• Strings are used for storing text
• How to concatenate strings?
• Use the + operator between strings to add them together
to make a new string

Output:
Juan Dela Cruz

COMPUTER PROGRAMMING 2 9
What are Strings?
• How to concatenate strings?
• Use the append() function between strings to add them together
to make a new string
• To use the append() function, add the <string> library in the
header portion

Output:
Juan Dela Cruz

COMPUTER PROGRAMMING 2 10
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 11
COMPUTER PROGRAMMING 2 12
COMPUTER PRORAMMING 2

You might also like