1/99
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
C++ is an extension of
Extension of C
C++ supports _
Supports procedural, object-oriented and generic programming
C++ regarded as _
Coding language regarded as middle level language combines high and low-level language features
C++ developed by
Developed by Bjarne Stroustrup
When was C++ developed?
Developed in 1979 at Bell Labs in Murray Hill, New Jersey
Original name of C++
is C with Classes, later renamed C++ in 1983
Preprocessor directives are
they include the sharp symbol and include pre-written code that you can use to perform specific tasks, they tell the compiler to preprocess the source code before compiling
Comments are
they use the backslash symbol // or backslash with asterisk /* */ to leave notes in the codes that wont affect the code itself
main() function is
it is called the int main()
{ indicates
it is the start of the program
it is the output statement
called the cout or character output
} indicates
it is the end of the program
iostream inclusions
examples: cin, cout
math.h includes
examples: pow, sqrt
define directive
used to define symbolic names and constants
Block Comment
Their purpose is only to allow the programmer to insert notes or descriptions embedded within the source code
using namespace std;
All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std (standard).
int main ()
The function named main is a special function in all C++ programs; it is the function called when the program is run. Semi colon is NOT required at the end.
Program statement
A statement is a simple or compound expression that can actually produce some effect.
compound statement,
also called a block, is a group of two or more C++ statements enclosed in braces
return 0;
This defines the exit status of the process or application. It terminates main( )function and causes it to return the value 0 to the calling process
keywords
are reserved words with special meaning in C++.
identifier
a name used to identify a variable, function, class, module, or any other user-defined item
variable
known as user-defined identifier. It is a data storage location that has a value, which can change during program execution.
data types
used to tell the variables the type of data it can store
Datatype Modifiers are used
modify the length of data that a particular data type can hold. ex, signed unsigned short long
int is
integer; requires 4 bytes of memory
char is
character, req 1 byte of memory
bool is
boolean, used for storing boolean or logical values. A boolean variable can store either true or false
float is
floating pont used for storing single precision floating point values or decimal values req 4 bytes of memory
double is
double floating point used for storing double precision floating point values or decimal values requires 8 bytes of memory
void
represents a valueless entity or without any value. It is used for those function which does not returns a value
wchar_t is
Wide Character, also a character data type but has a size greater than normal 8 bit datatype. generally 2 or 4 bytes long
global
Outside of all functions, including the main() function
local
Inside the function. Variables in this way are called _ variables and may be used only by statements that are also in the same function
constant
expression that has a fixed value.
constant must be enclosed between _
a character must be enclosed between single quotes
string constant is enclosed by _
it is enclosed by double quotation
Integer numbers
are specified as numerical (whole number) constants without fractional components. No need to write quotes (“) to express a numerical constant.
Operators
symbols that tell the compiler to perform specific mathematical or logical manipulations.
Assignment Operator
gives value to a variable (a single equal sign)
Arithmetic operator
perform addition, subtraction, multiplication, division, exponentiation, and modulus operations.
operator precedence
specifies the order of operations in expressions that contain more than one operator (remember PEMDAS; parentheses, exponents, multiplication, division, addition and subtraction)
compound operators
consist of a binary operator and the simple assignment operator. They perform the operation of the binary operator on both operands and store the result of that operation into the left operand, which must be a modifiable lvalue.
increment operator
is ++, adds 1 to its operand
decrement operator
is —, subtracts 1 from its operand
relational operators
operators that allow the comparison of two or more numerical values, yielding a result based on whatever the comparison is true(1) or false(0).
logical operators
used to combine two or more conditions or to complement the evaluation of the original condition in consideration. The result of the operation of a logical operator is a boolean value either true or false.
bitwise operators
characters that represent actions (bitwise operations) to be performed on single bits, will be turned to binary
& is
bitwise AND
| is
bitwise inclusive OR
^ is
Bitwise exclusive OR
~ is
Unary complement NOT
« is
Shift bits left SHL
» is
Shift bits right SHR
Conditional operators
also called as ternary operators, used to evaluate a condition that's applied to one or two boolean expressions
elements of c++ are
keywords
character set
data types
identifiers
operators
primitive data types
built-in/pre-defined data types and can be used directly by the user to declare variables and can be used to present data as characters, integers, floating-point numbers and boolean values
constructor initialization
enclosing the initial value between parentheses
3 places where variables can be stored
Outside the int main() called global
inside the function called local
in the declaration of a formal parameter of a function
input and output (I/O) operators are used
take input and display output
extraction (»)
operator used for taking the input or get from operator
insertion («)
operator used for displaying the output, put to operator
iostream
standard input and output stream objects are declared
screen
standard output by default, cout
keyboard
standard input by default, cin
getline()
a standard library function in C++ and is used to read a string or a line from input stream.
takes the stream (cin) as first argument, and the string variable as second.
Type Conversion
process of converting one predefined type into another.
Implicit
automatic type conversion. performed by the compiler without programmer's intervention.
type casting
The explicit conversion of an operand to a specific type