0% found this document useful (0 votes)
9 views2 pages

Week 3 Review Variables and Assignments Continued

Uploaded by

k61ca.2242219031
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Week 3 Review Variables and Assignments Continued

Uploaded by

k61ca.2242219031
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Monday

● The modulo operator (%) is a binary arithmetic operation that returns the remainder of a
division between two numbers. The modulo operator offers a means to perform modular
division, efficiently determining the remainder of an integer division. It's a versatile tool
with applications ranging from basic arithmetic operations to advanced programming
patterns and logic.

● Modulo is frequently used to determine the remainder when one integer is divided by
another.

● The modulo operator can be used to check if a number is even or odd. IE. if
someNumber % 2 == 0 then the number is even, otherwise odd.

● Modulo is useful in random number generation where you need to confine numbers to a
specific range.

● Using a divisor of 0 will lead to undefined behavior. Always ensure the divisor is non-
zero before performing the modulo operation.

● The modulo operator works with integers.

● The behavior of the modulo operator with negative operands is consistent in C++11 and
later. Specifically, the sign of the result is the same as the dividend. For example, -7 % 3
would result in -1.

● The cmath library in C++ provides a suite of built-in mathematical functions that ensure
precision, efficiency, and platform-independent behavior.

● The sqrt function from the cmath library computes the square root of a number.

● The pow function from the cmath library computes the power of a number raised to an
exponent.

● The fabs function returns the absolute value of a floating-point number, which is the
non-negative value of its argument.

● The abs function returns the absolute value of an integer number, which is the non-
negative value of its argument.
Wednesday
● Implicit Type Conversion (Coercion):
○ This happens automatically when the compiler encounters a situation where a
specific data type is expected but a different one is provided.
○ 10 / 3.0 // results in 3.333… because the result is implicitly cast to double.

● Explicit Type Conversion (Type Casting):


○ This is done intentionally by the programmer to specify that a variable should be
treated as a different type.
○ static_cast<target-type>(variableIdentifier)

● Binary representation is the system computers use to store and process data, and it's
based on two states: 0 and 1. These states can be thought of as "off" and "on",
respectively.

● When numbers, letters, or other symbols are saved in a computer, they are converted
into sequences of 0s and 1s. These binary sequences are used because electronic
devices (like computer processors) can efficiently differentiate between the two states
(on/off, high/low, etc.) to read, process, and store data.

Friday
● The char data type is a fundamental data type in C++ used to store a single character. It
typically requires 1 byte of memory, which means it can represent 256 distinct values.

● The escape character is a backslash ( \ ). It's used to represent certain characters within
string literals and characters that otherwise have a specific meaning, such as newline,
tab, double quote, and single quote.

● A string is a sequence of characters used to represent text. It can be managed using the
standard library class std::string, which provides various functions for string manipulation
and handling. Strings are enclosed in double quotes, like "Hello, world!".

● When you use the cin object (from the iostream library) to read input into a std::string
variable, by default, it reads characters only up to the first whitespace encountered.
Whitespace includes spaces, tabs, and newline characters. The function getline(cin,
stringVar) gets all remaining text on the current input line, up to the next newline
character

● Quiz

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy