Send a link to your students to track their progress
43 Terms
1
New cards
C++
cross-platform language that can be used to create high-performance applications
\ gives programmers a high level of control over system resources and memory
2
New cards
Bjarne Stroustrup
developed C++
3
New cards
Structure of a Program
best way to start learning programming by writing a program
4
New cards
//
are considered comments and do not have any effect on the behavior of the program
5
New cards
\#include
are directives for the preprocessor.
\ are not regular code lines with expressions but indications for the compiler's preprocessor.
6
New cards
using namespace std;
in order to access its functionality we declare with this expression that we will be using these entities.
7
New cards
;
tells the compiler that you're at the end of a command
\ separation between statements
8
New cards
int main ()
corresponds to the beginning of the definition of the main function
9
New cards
cout<<
represents the standard output stream in C++, and the meaning of the entire statement is to insert a sequence of characters
10
New cards
cin>>
character input
11
New cards
return 0;
causes the main function to finish
12
New cards
Variables
a name given to a memory location.
\ the basic unit of storage in a program.
13
New cards
Declaration of variables
to write the specifier of the desired data type (like int, bool, float...) followed by a valid variable identifier
14
New cards
Initialization of variables
is done by appending an equal sign followed by the value to which the variable will be initialized
\ other way to initialize variables, known as constructor initialization, is done by enclosing the initial value between parentheses (())
15
New cards
Operators
used to perform operations on variables and values
16
New cards
Arithmetic Operators
used to perform common mathematical operations
17
New cards
\+
addition
18
New cards
\-
subtraction
19
New cards
\*
multiplication
20
New cards
/
division
21
New cards
%
modulus
22
New cards
\++
increment
23
New cards
\--
decrement
24
New cards
Assignment operators
used to assign values to variables
25
New cards
Comparison Operators
are used to compare two values
26
New cards
==
equal to
27
New cards
!=
not equal
28
New cards
>
greater than
29
New cards
<
less than
30
New cards
>=
greater than or equal to
31
New cards
less than or equal to
32
New cards
Logical Operators
used to determine the logic between variables or values
33
New cards
&&
and
34
New cards
| |
or
35
New cards
!
not
36
New cards
String
used for storing text.
\ contains a collection of characters surrounded by double quotes (“)
\ you must include an additional header file in the source code, the library
37
New cards
String Concatenation
The + operator can be used between strings to add them together to make a new string.
38
New cards
Adding Numbers and Strings
* C++ uses the + operator for both addition and concatenation. * Numbers are added. Strings are concatenated.
39
New cards
String Length
use the length() or size() function. It is completely up to you if you want to use length() or size()
40
New cards
Access Strings
referring to its index number inside square brackets \[\].
\ String indexes start with 0: \[0\] is the first character. \[1\] is the second character, etc
41
New cards
Change String Characters
refer to the index number, and use single quotes.
42
New cards
User Input Strings
It is possible to use the extraction operator >> on cin to display a string entered by a user
43
New cards
getline() function
* getline() is a standard library function that is used to read a string or a line from an input stream. * It takes cin as the first parameter, and the string variable as second