W3School
! Logical not
! reverse the result, returns false if the result i
This is a single-line comment This is a multi-line comment
// /* */
cout
the standard output stream object in C++; used with the insertion operator to display information on the computer screen
\n
used as an escape sequence
using namespace std;
we are able to use for objects and variables from the standard library
int main() {}
the main function where the program execution begins
int x = 5; int y = 6; int sum = x + y; cout << sum;
11
variables
All C++ variables must be identified with unique names. These unique names are called identifiers. Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
--
Decrement decreases the value of a variable by 1
/
Division
==
Equal to
>
Greater than
>=
Greater than or equal to
++
Increment increases the value of a variable by 1
<
Less than
<=
Less than or equal to
%
Modulus returns the division remainder
|| (logical OR)
Returns True if one of the statements is true Ex. ( x < 5 || x <4 )
&& Logical and
Returns true if both statements are true Ex. ( x < 5 && x < 10 )
const
When you do not want others (or yourself) to change existing variable values, use the const keyword (this will declare the variable as "constant", which means unchangeable and read-only):
+
addition
#include <iostream>
header file library that lets us work with input and output objects
int myNum = 15; myNum = 10; cout << myNum;
if you assign a new value to an existing variable, it will overwrite the previous value.
<<
is used to output text
//
make comments that wont interfere w the program
*
multiplication
\n
new line
endl;
new line
!=
not equal
double
stores a floating-point number, with decimals, such as 19.99 or -19.99
int
stores integers (whole numbers), without decimals, such as 123 or -123
char
stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
string
stores text, such as "Hello world". String values are surrounded by double quotes
bool
stores values with two states: true or false
-
subtraction