1/154
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Building data structures and algorithms
It requires communicating instructions to a computer, and an excellent way to perform such communication is using a high-level computer language.
high-level computer language
Building data structures and algortihms requires communicating instructions to a computer, and an excellent way to perform such communication is using a _____________.
C++
It is a powerful and flexible programming lanauge, which was designed to build upon the constructs of the C programming language. It is a superset of the C programming language.
C++
Extension to C language developed by Bjarne Stroustrup at Bell Labs
Bjarne Stroustrup, Bell Labs
Who developed and where was C++ developed?
C++ Program
It is a collection of commands, which tell the computer to do "something".
C++ Source code
A C++ program is a collection of commands, which tell the computer to do "something". This collection of commands is usually called ____________.
Commands
are either "functions" or "keywords".
Keywords
are a basic building block of the language.
Functions
are, in fact, usually written in terms of simpler functions.
Reasons to Learn C++
❑ Popularity and High Salary
❑ Abundant Library Support
❑ Large Community
❑ Databases
❑ Operating Systems
❑ Compilers
❑ Web Browsers
❑ Graphics
❑ Embedded Systems
❑ Portable
Data Type
Classification that specifies which type of value a variable has and what type of mathematical, relational, or logical operations can be applied to it without causing an error.
Data Type
It has Primitive and Composite
Primitive Data Type, Composite Data Type
These are the two types of Data types in C++
Primitive Data Type
This data type only reads only one value, digit, or character.
Primitive Data Type
Example of this are: int = 3, char = ‘k’, float = 23.5, double = 23.0
Composite Data Type
It consists of multiple values, digits, or characters.
Composite Data Type
Example of this are: string, arrays, etc.
Arrays
collection of homogenous data types
Vectors
mathematical representations of arrays
Strings
combination of characters
Arithmetic Operators
Operators used for mathematical calculations.
+
adds two operands
-
Subtract
*
Multiples both operands
/
Divides numerator by de-numerator
%
gives the remainder of after an integer division
modulus
%
++
increases integer value by one
increment operator
++
decrement operator
--
Relational Operators
Operators used to compare values.
==
Checks if the values of two operands are equal or not, if yes then condition becomes true.
!=
Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.
>
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.
<
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.
>=
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.
<=
Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.
Logical Operators
Operators used to combine or modify conditions.
Logical AND Operator
If both the operands are non-zero, then condition becomes true.
Logical AND Operator
Represented by &&
Logical OR Operator
If any of the two operands is non-zero, then condition becomes true.
Logical OR Operator
Represented by ||
Logical NOT Operator
Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false.
Logical NOT Operator
Represented by !
Bitwise Operators
Operators used to perform operations at the bit level.
Binary AND Operator
copies a bit to the result if it exists in both operands.
&
Binary AND Operator
It gives the binary bit of a value.
Binary OR Operator
copies a bit if it exists in either operand.
|
Binary OR Operator
It has rules of:
1 and 1 = 1
0 and 0 = 0
1 and 0 = 0
Binary XOR Operator
copies the bit if it is set in one operand but not both.
^
Binary XOR Operator
It has rules of:
1 and 1 = 0
0 and 0 = 0
1 and 0 = 1
Binary Ones Complement Operator
is unary and has the effect of 'flipping' bits.
~
Binary Ones Complement Operator
It flips the binary bits of a value.
Binary Left Shift Operator
The left operands value is moved left by the number of bits specified by the right operand.
«
Binary Right Shift Operator
The left operands value is moved right by the number of bits specified by the right operand.
»
Assignment Operators
Operators used to assign values to variables.
=
Simple assignment operator, Assigns values from right side operands to left side operand.
Add AND assignment operator
It adds right operand to the left operand and assign the result to left operand
+=
Subtract AND assignment operator
It subtracts right operand from the left operand and assign the result to left operand.
-=
Multiply AND assignment operator
It multiplies right operand with the left operand and assign the result to left operand.
*=
Divide AND assignment operator
It divides left operand with the right operand and assign the result to left operand.
/=
Modulus AND assignment operator
It takes modulus using two operands and assign the result to left operand.
%=
Left shift AND assignment operator.
<<=
Right shift AND assignment operator.
>>=
Bitwise AND assignment operator.
&=
Bitwise exclusive OR and assignment operator
^=
Bitwise inclusive OR and assignment operator.
|=
Misc Operators
Operators that do not fall under other categories.
sizeof
returns the size of a variable. For example, sizeof(a) where ‘a’ is an integer and will return 4.
sizeof
it gives the size of bytes that a variable takes up.
sizeof
int main() {
float b = 10;
cout << sizeof(b) << " with value of: " << b <<endl;
return 0;condition ternary operator
it is considered the “shortcut” or easier way of an if-else statement.
conditional ternary operator
if condition is true, then it returns value of X, otherwise returns value of Y.
condition ternary operator
represented by ? x : y
X
In condition ternary operator ? x : y, what is returned if the condition is true?
Y
In condition ternary operator ? x : y, what is returned if the condition is false?
condition ternary operator
int main() {
int a = 10, b = 5, c = 0, d = 1;
int result = (a == b) ? d : c;
cout << "Result: " << result << endl;
return 0;address and pointer
represented by *ptr
address and pointer
int main() {
int x = 10;
int *ptr = &x;
cout << "Address: " << &x << endl;
cout << "Value: " << *ptr << endl;
return 0;comma
causes a sequence of operations to be performed.
comma
represented by ,
comma
the value of the entire _______ expression is the value of the last expression of the comma-separated list.
dot and arrow
it is considered the member operators.
dot
represented by .
arrow
represented by →
member operators
are used to reference individual members of classes, structures, and unions.
dot and arrow
struct Student {
int id; //102
};
int main() {
Student s;
s.id = 101;
Student *ptr = &s;
ptr->id = 102;
cout << s.id << endl;
return 0;Set the class, struct Student including the variable int id;
Establish the class Student as the variable name s
s.id tells that the class Student has the variable int id
structure
struct Student {
int id; //102
};struct
is used to create a custom data type.
members
inside a structure, you define variable or called ______.
casting operators
convert one data type to another. for example, int(2.200) would return 2.
casting
int main() {
float num = 3.9;
int result = (int)num;
cout << result << endl;
return 0;Pointer operator &
returns the address of a variable in HEXADECIMAL form. For example &a; will give actual address of the variable.
Pointer operator *
is pointer to a variable. For example *var; will pointer to a variable var.
semicolon
a statement terminator.
semicolon
each individual statement must be ended with a __________-.
semicolon
It indicates the end of one logical entity.
blocks
is a set of logically connected statements that are surrounded by opening and closing braces.
identifier
is a name used to identify a variable, function, class, module, or any other user-defined item.