Comp-Reviewer - G9
Comp-Reviewer - G9
Array - collection of variables of the same data type; groups of data of the same type referenced under
one name; collection of data storage locations
datatype arrayName[size];
ELEMENTS OF AN ARRAY:
example of an ARRAY:
int exam[4];
Initializing Array – to initialize, value are assigned right after their declaration (Creation) with the use of
Assignment operators (+, -, *, /, =)
Multidimensional Arrays – Arrays that can be represented using more than one dimension
Initializing Multidimensional Arrays – Uhm, how do I explain? (First size value = number of elements in
group, second size value = number of groups) (Size value is [size])
Structured Data Type - a number of distinct data items, of different types, grouped together as one unit
Asterisk (*) – Used to tell the compiler to reserve a memory space that can hold a memory address
Garbage Values – HAS NO USE; INSIGNIFICANT VALUES; USELESS; Values assigned to declared variables
when not initialized
*ptr - if ptr is declared as a pointer, this translates to “the contents of the address stored in the variable
ptr”
EVERY C++ PROGRAM HAS ATLEAST ONE FUNCTION which is always main()
1. A function must be declared prior to its use except when it is already defined.
2. The parameter list of a function may have parameters of any data type.
3. Parameters are optional.
4. The number and data types of parameters should match the number and data types of the arguments
passed on to it.
5. The return statement is used to return a single value from a function. It usually appears at the last line
of a function but it may also appear anywhere within a function.
6. The return statement is optional.
7. If the data type of the value returned by a function is not declared, it is converted to int.
8. If a function does not return a value, its return type will be void.
Pass-by-Reference Method - parameters only accept values from other functions of the program;
arguments and parameters refer to the same memory location; addresses of arguments are passed
it is valid to give several functions the same name. The only requirement is that it should have a different
set of parameters, whether data types or a number of parameters.
Tldr: function can use same name, but need different set of parameters or data type
Overloading Functions – Function use same name but different set of parameters or data type; Example
of polymorphism; allows functions to have many forms
Arguments - values which may be variables or expressions passed on to the function and are normally
found in the function call
Indirection Operator (*) - returns the value of the address stored by the pointer
Return Values - the results of the function which may be passed to another function
Function Prototype – datatype functionName (Parameter List); - way of identifying the data types of any
return value and parameter for the compiler so it can perform error-checking