Order of Operations
Scope
Boolean Operations
Ifs and Switches
File IO
Recursion
Object Oriented Programming
apvector/apmatrix
apstring
sorting
searching
vocabulary


Notes on Order of Operations

+ addition

- subtraction

* multiplication

/ division

% modulus (remainder) (integer operations only)

  1. All expressions within a set of parentheses are evaluated first. If there are parentheses within parentheses (nested parentheses), the innermost expressions are evaluated first

  2. The operations *, %, and / are evaluated next in order from left to right

  3. The operations + and – are evaluated last from left to right


    • Boolean Operators – Using Boolean expressions will return “True” or “False”

== (is equal to)

< (is less than)

> (is greater than)

<= (is less than or equal to)

>= (is greater than or equal to)

! (not)

!= (is not equal to)

&& (and)

|| (or)

  1. ( )

  2. !

  3. *, /, %

  4. +, -

  5. <, <=, >, >=, ==, !=

  6. &&

  7. ||

    • == and =

== means “is equal to”, while = assigns a value to a variable

If there is a compound Boolean expression with a &&, then if one expression returns “false,” then the entire expression is false

If there is a compound Boolean expression with a ||, then if one expression returns “true,” then the entire expression is tru




Boolean operations including DeMorgan's Law

Boolean: expression; can be true(any value but 0) or false(0)

relational operator- used to compare data of same type


arithmetic op relational op

= = = is equal to

< < is less than

> > is greater than

≤ < = is less than or equal to

≥ > = is greater than or equal to

≠ ! = is not equal to


simple boolean expression – two numbers/variables compared with ONE relational operator; will return true or false

ex. – c = = c would return true; -5 >= 10 would return false…


arithmetic expressions can be used in boolean expressions; order of priority in evaluation:


expression priority

( ) 1

*, /, % 2

+, - 3

= =, <, >, < =, > =, ! = 4


logical operators – logical connective or negation (used with simple boolean expressions)

complete expression called compound Boolean expression

conjunction – AND && - returns true if both true

disjunction – OR | | - returns true if either one is true

negation – NOT ! – returns true if false; false if true


priority evaluation for logical ops: 1. ! 2. && 3. | |


overall priority of evaluation list for relational/ logical ops + arithmetic ops:

expression or operation priority (evaluate from:)

( ) inside to out

! left to right

*, /, % left to right

+, - left to right

<, <=, >, >=, = =, != left to right

&& left to right

| | left to right

short-circuit evaluation – a compound Boolean expression halts evaluation early and:

if connected by || returns true for first expression that is true

if connected by && returns false for first expression that is false

deMorgan’s law:

not (x and y) = (not x) or (not y)

not (x or y) = (not x) and (not y)



Notes on scope

What is the Scope of an identifier?


/***************************************

const double PI = 3.14;


double circle(int radius)

{

double area;

area = PI*radius*radius;

return area;

}


main()

{

int r = 2;

int A;

A = circle(r);

}

*****************************************/

In this code:

Examples:

Names of Identifiers:


Also click here


Notes on File IO

INPUT/OUTPUT STREAMS

-An input file stream is used to receive input from a file, and an output file stream is used to send output to a file. To access file stream operations, you must type #include <fstream.h> in your program.

-When declaring file streams, you must set them to either type ifstream(input file stream) or ofstream(output file stream):

-ifstream in_file;

-ofstream out_file;

-To open and close file streams:

-in_file.open(“myfile”);

-in_file.close();

-To detect errors in opening or closing files, a .fail function can be used. This function returns true if the program fails to open or close a file, and false otherwise.

- assert(! out_file.fail()); //this requires assert.h

-To read from an input file, the >> operator is used, and to write to an output file, the << operator is used. Whitespace characters are used as separators between data values.

-out_file<<variable<<” “<<endl;

-in_file>>variable;

//This reads in data from the input file and stores it in variable

-The .eof function is used to detect the end of a file. It returns true if there is no more data to be read from the input file, and false otherwise.

-in_file>>data; //priming input statement- this is used to make //sure the program runs correctly even if the //file has no data

while (! in_file.eof())

{

process(data);

in_file>>data;

}

-A line of text can be read from an input file by using the getline function, as shown. You need to include apstring.cpp in your program for this to work.

-getline(in_file,data);

-For character input and output, get and put are used in place of >> and << to read data to input files and write data to output files. Get and put deal with one character at a time, and this includes whitespace characters.

-in_file.get(ch)

-out_file.put(ch)


Also click here


Notes on Recursion

Recursion Review


In order to use Recursion, there are two things that are required:
1.A base case (stop condition is required). Without a base case/stop condition, the function will loop infinitely because nothing will tell it to break out of the loop
2.A recursive step. The function must also progress closer to the answer or else the function may not fulfil the base case and cause another infinite loop.

Recursion may not be as efficient as other ways of solving the problem, but it is easy to implement and can work for a large array of problems.

For example, if it was necessary to create a function that could find the sum of a arithmetic series An=2(n) there could be two ways to write it:

For loop format:
Cout  << “enter S (the number you want to sum to)”// for example s=1 has a sum of 2(1)=2     n=2 has a sum of    2(1)  +  2(2)   =6
Cin >> n;

For (int a=0; a<n; n++){
Total+=2*n;
}
return total;
}


Recursive Format:
//precondition: a=0, n= number of sum
Void Sum(int n, int a){

If (n==a) return 0; // this is the base case; if this is true, then it provides the first “answer” that the computer uses to solve the entire return statement

Else {
Return 2*N+sum(n-1, a);//this is the recursive step which increases a, causing it to get closer to the answer
}


There are Also 2 types of Recursion: Tail Recursion and Embedded Recursion
1.Tail Recursion: Tail recursion uses another Reference parameter as a argument to store the current value; thus with tail recursion the current value can be known.
2.Embedded recursion does not need the Reference paramter as tail recursion does, but instead returns a statement that will only be visible when the recursive step reaches the base case and allows the computer to calculate the return statement. Using Embedded recursion prevents the programmer from accessing the current value.


Example of tail recursion:
//precondition: a=0, n= number of sum
Void sum(int a, int n, int &result) // 1 extra argument for storing result
If (a==n) result+=0;
Else{
Result+=2*n;           // current value can be accessed
Sum(a, n-1, result)
}

Embedded recursion:
Int sum(int a, int n) // no extra argument
If (a==n) return 0;
Else{
Return (a, n-1)//current value is unknown, return statement cannot be evaluated until (a==n)
}



If there is a situation where using Recursion (either tail or embedded) would be difficult, it is possible to use a helper function.
A helper function allows the recursive function to work without requiring an additional variable.

Also click here and here


Notes on Object Oriented Programming

Object-Oriented Programming (OOP)

What is an Object?

An object is a software bundle of related variables and methods. Software objects are often used to model real-world objects you find in everyday life.

Public:

Can be accessed anywhere the class is present

Private:

Can only be accessed by the .H file and the .CPP implementation file for the given class

Assessors:

Public by definition, returns the value of a private variable

Modifier:

Public by definition, allows an external way to modify private variables

Those are the bare basics.


How to create a Class:

Step 1:

Class NAME

Step 2:

{

Public:

Private:

};

Step 3:

Fill them in (privates and publics)


Example

class my_class_of_songs

{

public:

my_class_of_songs() ; // constructor, needed for declaration of variables

//accessor

apstring get_names() const; // accessor, returns the apstring which holds the value of the // name

// modifier

void set_names(); //modifier that sets the private variable which has the value of the name

private:

apstring name; // has a value for every different variable of my_class_of_songs

};

example of implementation:

my_class_of_songs::my_class_of_songs(){}

// empty because you are not setting any values, just creating a variable of type // my_class_of_songs

apstring my_class_of_songs::get_names() const{

return name;

}

// returns the value of the private variable name because the private is block, you have to //make a modifier

//its const to keep the value safe

void my_class_of_songs::set_names(){

cout << “Please enter the name of the song: “;

getline(cin,name);

}




Notes on if and switch


if score >= 50

if score > 69

cout << "Your progress is satisfactory.";

else

cout << "Your progress is unsatisfactory.";

else

cout << "You are currently failing.";

If the score is greater than or equal to 50, this code will either display satisfactory or unsatisfactory. Otherwise, it will say that you are failing.



if (<condition 1>)

//action 1 here

else if(<condition 2>)

//action 2 here

else if(<condition 3>)

//action 3 here

else

//action 4 here



if (score > 69)

cout << "Your progress is satisfactory.";

if ((score <= 69) && (score >=50))

cout << "Your progress is unsatisfactory.";

if (score < 50)

cout << "You are currently failing.";


Switch(<selector>)

{

case <label 1>: <statements 1>

break;

case <label 2>: <statements 2>

break;


. .

case <label n>: <statements n>

break;

default: <statements>

}

switch (age)

{

case 30: cout << "Happy 30th birthday";

break;

case 20: cout << "Happy 20th birthday";

break;

case 10: cout << "Happy 10th birthday";

break;

default: cout << "There is no case for " << age << endl;

}




Notes on Apstring

Implementing apstring
You can use >>  to declare a string or if you need to keep the spaces in a sentence for example you use getline.

 apstring name;
 {cout<<“enter your full name:”;
 getline(cin, name);}

Substrings are individual characters within a string.

Int main()
 {
 apstring my_string;
 my_string = “Hi there!”;
 cout<<my_string.find(“here”)<<endl;
 }
that will output 4 since that is the starting index position of here.

You use C_str to convert a string variable to a string in C format.
Its normally used for opening files.

    Cout<<“enter the output file name:”;
    Cin>>file_name;
    Out_file.open(file_name.c_str());

To find the length of an apstring you can use whatever you used to declare your apstring like name.  To find the length you say name.length() which should output the length in my case 9.


Notes on apvector/apmatrix

AP Vector

  • A vector is a one dimensional array that provides range checking and can be resized.

  • Basically, any operation that can be used on an array can be used on the vector as well.

  • Attributes of a vector:

    • mySize-vector’s capacity

    • myList-vector’s data elements

    • itemType-vector’s element type

      • class template is a kind of class that allows its component types to be specified as parameters:

    • ex. Apvector<vector type> (name).

  • pointers are variables that can hold the address of a memory location, just ‘pointing’ to the location rather than being the location.

  • Can use the notation:

    • :mySize(0), myList(0) to set the vectors to zero rather than,

    • mysize=0;myList=0;

      • set a memory location by doing: <pointer value>=new<item type>[<number of items>]

      • destuctor is a function that returns dymanic memory for an object of the system, pretty much destroys the memory location:

    • ex. delete[] myList;

  • declaration of index: <name>[number of locations]

AP Matrix

  • a matrix is basically a vector, but with two dimensions

  • attributes of matrix:

        • myRow-gets the number of rows

        • myCols-get number of columns

        • myMatrix-data elements

        • itemType-matrix element type

  • declaration of index: <name>[number of rows][number of columns]



Notes on sorting

Click here



Notes on searching

// Sequential search
// Starts from the first item, then searches each of the components until the desired item is found
// In the worst case, it will search through every element in the list
// If you are lucky, and the first item is the desired item, then it is very quick

// For example:

apvector<int> vector(100);
int index;
// then all the numbers are inputted
// to search for a certain number entered
for (int a = 0; a < a.length()-1; a++)
{
    if (vector[a] == (the desired number))
    {
        index = a
    }
}
// then the location of the desired number is known
// but this takes a long time with huge lists


// Binary search

// All the elements need to be in order for this to work
// this will not work if the list is not sorted
// Quickly finds the desired element in large arrays and vectors
// Takes guesses using the midpoint

// it is probably easier to use recursion and functions

// Example code
// target is the item that is searched for, first is initially 0, and last is vector.length()-1
int binary_search(int target, apvector vector, int first, int last)
{
    if(first > last) return –1;
    else
    {
        int midpoint = (first + last)/2;
        if (vector[midpoint] == target) return midpoint;

        else if (vector[midpoint] > target) return binary_search(target, vector, first, midpoint - 1);
        // if the guess is too high, search the numbers that are lower than the guess

        else if (vector[midpoint] < target) return binary_search(target, vector, midpoint + 1, last);
        // if the guess is too low, then search the elements above the guess
    }
}


Chapter Vocab

Chapter 1

Algorithm: A finite sequence of effective statements that, when applied to a problem, will solve it.

Programming language: A formal language that computer scientists use to give instructions to a computer.

Data: The particular characters that are used to represent information in a form suitable for storage, processing, and communication.

Mainframe: A large computer typically used by major companies and universities.

Minicomputer: A small version of a mainframe computer. It is usually used by several people at once.

Microcomputer: A computer capable of fitting on a laptop or desktop, generally used by one person at a time.

Workstation: A powerful desktop computer that uses microprocessor technology.

Network: A group of computers that are linked to share resources.

Client/server relationship: A means of describing the organization of computing resources in which one resource provides a service to another resource.

Hardware: The physical computing machine and its support devices.

Software: Programs that make the machine do something, such as word processing, database management, or games.

Program: A ser of instructions that tells the machine what to do.

Main unit: A computer’s main unit contains the CPU and the main memory; it is hooked up to an input and an output device.

Central processing unit (CPU): A major hardware component that consists of the arithmetic/logic unit and the control unit.

Main primary memory (aka random access memory): Memory contained in the computer.

Arithmetic/logic unit: The part of the CPU that performs arithmetic operations and evaluates expressions.

Control unit: The part of the central processing unit that controls the operation of the rest of the computer.

Execute: To carry out the instructions of a program.

Binary digit (aka bit): A digit, either 0 or 1, in the binary number system. Program instructions are stored in memory using a sequence of binary digits. Binary digits are called bits.

Input device: A device that provides information to the computer. Typical devices are keyboards, disk drives, card readers, and tape drives.

Output device: A device that allows you to see the results of a program. Typically it is a monitor or a printer.

Secondary memory device: An auxiliary device for memory, usually a disk or magnetic tape.

I/O device: Any devices used for input or output.

Bus: A group of wires imprinted on a circuit board to facilitate communication between components of a computer.

Modem: A device that connects a computer to a telephone system to transmit data.

System software: The programs that allow users to write and execute other programs, including operating systems such as DOS.

Application software: Programs designed for a specific use.

Operating system: A large program that allows the user to communicate with the hardware and perform various management tasks.

Machine language: The language used directly by the computer in all it’s calculations and processing.

Assembly language (aka low-level language): A computer language that allows words and symbols to be used in an unsophisticated manner to accomplish simple tasks.

High-level language: Any programming language that uses words and symbols that make it relatively easy to write a program.

Compiler: A computer program that automatically converts instructions in a high-level language to machine language.

Source program: A program written by a programmer.

Object program (aka object code): The machine code version of the source program.


Chapter 2 

Effective statement: A clear, unambiguous instruction that can be carried out.

Top-down design: A methodology for solving a problem whereby you first state the problem and then repeatedly subdivide the main task into subtasks until each remaining subtask is easily solved.

Stepwise refinement: The process of repeatedly subdividing tasks into subtasks until each subtask is easily accomplished.

Module: An independent unit that is part of a larger development. Can be a function or a class.

Structure chart: A graphic method of indicating the relationship between modules when designing the solution to a problem.

Module specifications: A description of data received, information returned, and the task preformed by a function.

Pseudocode: A stylized half-English, half-code language written in English, but suggesting C++ code.

Software engineering: The process of developing and maintaining large software systems.

Software system life cycle: The process of development, maintenance, and demise of a software system.

Object-oriented design: A methodology that uses small, reusable components to construct large software systems.

Reserved words: Words that have predefined meanings that cannot be changed.

Library identifiers: Words defined in standard C++ libraries.

Programmer supplied identifiers: Words defined by the programmer.

Keywords: Either reserved words or library identifiers.

Syntax: The formal rules governing construction of valid statements.

Preprocessor directives: Statements that tell the C++ preprocessor to perform such tasks as combining source program files prior to compilation.

Constant and type definition section:An area of a C++ program where constant and type definitions are placed, usually near the beginning of the text.

Main program heading: A syntactic form that marks the beginning of the main program.

Main block: The main part of a program.

Declaration section: The section used to declare variables that are necessary to the program.

Statement section: An area of a C++ program where the executable statements are placed.

Executable statement: The basic unit of grammar in C++ consisting of valid identifiers, standard identifiers, reserved words, numbers, and/or characters, together with appropriate punctuation.

Comment: A non-executable statement used to make a program more readable.

Data type: A formal description of the set of values a variable can have.

Fixed-point form: A method of writing decimal numbers in which the decimal is placed where it belongs in the number.

Floating-point form: A method for writing numbers in scientific notation to accommodate numbers that may have very large or very small values.

String: A data type used to represent a word or line of text.

String constant: A word or a line of text enclosed in double quotes.

Standard output stream: An object to which a program sends data for output to a device, normally the terminal screen.

Format manipulator: A symbol that instructs the computer to display output in a specified format, such as right justified.

Test program: A short program written to provide an answer to a specific question.

Pixel: A picture element or dot of color used to display images on a terminal screen.

Coordinate system: A grid in which a point in space or a pixel on a computer screen can be located.


Chapter 3 & 4
  1. Word: a unit of memory consisting of one or more bytes. Words can be addressed.

  2. Integer overflow: When an integer value is too large to be stored in the computer’s memory.

  3. Round-off error: when a portion of a real number is lost because of the way it is stored in the computer’s memory.

  4. Underflow: When a value is too small to be represented by the computer, the value will be automatically replaced by zero.

Ex: 1.23 * 10^-20 = .0000000000000000000123 which will be stored as zero.

  1. Representational error: When the precision of data is reduced because of the order in which the operations are performed.

Ex: (-42.5 + 45.6) + .215 = .315 -45 + 45.6 yields .1. Then, .1 + .215 yields .315.

-45.5 + (45.6 + .215) = .3 45.6 + .215 yields 45.815. Since the hypothetical computer only yields three digits of accuracy, this result will be stored as 45.8. Then, –45.5 + 45.8 yields .3.

  1. Cancellation Error: When data are lost because of differences in the precision of the operands.

Ex: 2 + .0005 This value should be 2.0005, but stored to only three digits of accuracy, the result would be 2.00. In effect, the smaller of the two numbers is canceled from the expression.

  1. Mixed-mode expression: An expression containing data of different types; the resulting value of the expression will be of either type, depending on the rules for evaluating them.

Ex: In an expression involving both int and double data types, the value will be of type double.

  1. Memory location: a storage cell that can be accessed by address.

  2. Variable: If the contents of the memory location are to be changed during a program, it is called a variable.

  3. Constant: If the contents of the memory location can not be changed during a program, it is called a constant.

  4. Assignment statement: putting values into memory locations.

Ex: <variable name> = <value>; sum = 30; letter = ‘C’;

Or <variable name> = <expression>;

  1. Compound assignment: An assignment operation that performs an operation before storing the result in a variable.

Ex: x = x + y. This expression adds the value of x and the value of y, and then stores the sum in x.

  1. Self-documenting code: Code that is written using descriptive identifiers.

  2. Extractor: the standard input operator >>.

Ex: cin >> length;

  1. Inserter: the standard output operator <<.

Ex: cout << length;

  1. Collating sequence: The order sequence for a character set used by a machine.

Ex: ASCII

  1. Character set: the list of characters available for data and program statements.

  2. Concatenation: When the contents of one data structure are placed after another data structure.

Ex: apstring first, second, third;

first = “Hi”;

second = “ there”;

third = first + second;

cout << third;

This displays Hi there on the screen.

  1. Class: A description of the attributes and behavior of a set of objects.

  2. Member function: functions defined for a class.

Ex: word.length( );

<variable name>. <member function name>( );

  1. Seed: An initial value used by a random number generator.

  2. Type promotion: When the computer converts a less inclusive data type such as int, to more inclusive data type, such as double.

  3. Ordinal data type: A data type ordered in some association with integers.

Ex: Using ASCII, the ordinal of a capital a (‘A’) is 65.

  1. Type cast: an operation that converts the type of a data object.

Ex: <type name> (<expression>)

int (3.14);

25. Explicit type conversion: the use of an operation to convert the type of a data object.

  1. Subprogram: a program within a program.

  2. Abstract data type: A set of objects with a defined set of properties and operations for processing the objects.

  3. Modularity: The organization of the program into independent units.

  4. Bottom-up testing: the independent testing of modules.

  5. Structured programming: programming where the emphasis is placed on the flow of control between independent modules. Parallels a top-down design.

  6. Structured design: organizing communication between modules.

  7. User-defined function: a function introduced and defined by the programmer.

  8. Function declaration: consists of the function’s name, number and kind of arguments, and the type of value returned.

Ex: double pow(double base, double exponent);

  1. Function implementation: a complete, brief program that produces some effects if certain assumptions about the arguments to the function are satisfied.

  2. Function heading: looks like the function declaration only the semicolon following the right parenthesis is omitted.

  3. Formal parameter: a name that is declared and used in a function declaration that is replaced by an actual parameter when the function is called.

  4. Actual parameter: a variable in a function call that is passed to that function.

  5. Locally declared data: Data declared with a block, usually the block of the main program or a function.

  6. Stub programming: Using incomplete functions to test data transmission among them.

  7. Main driver: the main program when subprograms are used to accomplish specific tasks.

  8. Void function: A function that returns no value.

  9. Parameter mode: the way that a parameter is passed, such as by value or reference.

  10. Value parameter: when values are passed only from the caller to a function.

  11. Reference parameter: a formal parameter that requires the address of the actual parameter to be passed to a subprogram. The value can be changed within the subprogram.

<type name>&<formal parameter name>

  1. Alias: When two or more identifiers in program refer to the same memory location. Reference parameters in the function heading are merely aliases for actual variables used by the caller.

  2. Constant reference: a reference parameter that will not change in a function.

Ex. const <type name> & <parameter name>

apstring get_string (const apstring &prompt);

  1. Cohesive subprogram: a subprogram that performs a single task.

  2. Functional abstraction: considering only what a function is to do rather than details of the function.

  3. Precondition: a statement that is true before a certain action is performed.

  4. Postcondition: a statement of what is true after a certain action is taken.

  5. Information hiding: When the user does not know the details of how a module is implemented and the implementer does not know how the module is used.

  6. Interface: a statement of how communication occurs between the user of a subprogram and its implementer.

  7. Block: the global text of the program file.

  8. Subblock: a block structure for a subprogram.

  9. Scope of identifier: the area of the program text in which an identifier can be used.

  10. Global identifier: can be used in the main program and all subprograms.

  11. Local identifier: restricted to use within a subblock of a program.

  12. Side effect: a change in a non-local variable that is the result of some action taken in a program.

  13. Manifest interface: When the function is called, the reader of the code can clearly tell that a side effect will occur in the function, a what the side effect will be.

  14. Library header file: source code usually with a .h suffix, containing data and function declarations.

  15. Library implementation file: source code with a .cpp suffix containing function implementations.


Chapter 5

Selection statement- Selection statements are statements that permit the computer to make decisions. An if statement is a a type of selection statement.

Control structures- Selection statements are a form of control structures because it allows the programmer to control the flow of programming statements.

Boolean- is an expression that determines whether a value is true or false.

Type definition- type definitions are used to create new type names for declaring variables, function parameters, and function returns of the values.

Relational operator- These are operators used to compare data of the same type (ie. ==, <,>,<=,>=,!=0

Simple Boolean expression- is an expression that uses relational operators to compare two values, returning either true or false. (ie. 7 == 7)

Logical operator- && (meaning and), || (meaning or), ! (meaning not)

Conjunction- Is a boolean expression connected by the && symbol. It returns false if one expression is false or true if both of the expressions are true.

Disjunction- Is a boolean expression connected by the || symbol. It returns true if one expression is true or false if both expressions are false.

Negation- Is boolean expression using the ! symbol. It returns false if the expression is true or true if the expression is false.

Compound Boolean Expression- is an expression when logical operators are used with relational operators.

(ie. (4.2 >= 5.0) && (8 == (3+5)) )
Short circuit evaluation- this is a process that impedes an evaluation if the expression is true, in the case of ||, or false in the case of &&.

Compound statement- it is a statement that uses {} symbols to combine several statements together.

Statement block- it is a group of statements that can be treated as one statement.

Nested if statement- it an if statement within another if statement.

Extended if statement- a nested if statement with the addition of if else.

Assertion- Special comments that state what is expected to happen after a condition.

Program proof- an analysis of a program that attempts to verify the correctness of program results.


Chapter 6

Pretest loop- A loop where the control condition is tested befor the loop is executed. (ie. For loop, while loop)

Pretest condition- a condition tested at the top of the loop that controls whether the loop is executed.

Post-test loop- a loop where the loop is tested after it is executed. (ie. do while loop)

Fixed repetition loop- a loop used when the number of repetitions are known. (ie. for loop)

Variable condition loop- a loop used when the numbers of repetitions are unknown. (ie. whilw loop, do while loop)

Accumulator- a variable used in order to summing the successive values of some other variable.
(ie. for (lvc = 1; lvc <=100; ++lvc)
sum= sum+lvc;

Decrement- in a for loop the control variable is decreased by one.

Infinite loop- a loop where the control condition does not let the loop terminate.
(ie. a = 1;
while (a > 0)
{
num = 5;
count << num << endl;
}
cout << a ;

Sentinel value- a value that allows a loop to terminate when entered.

Counter- A variable used to count the number of times a process is needed to complete a task.

Data validation- The process of examining data before its use on a program.

Loop verification- the process of guaranteeing that a loop performs its intended task

Input assertion- a precondition for a loop

Output assertion- a postcondition for a loop

Loop invariant- is an assertion that expresses a relationship between variables that remain constant throughout the loop.

Loop variant- An assertion that changes from first and final execution of a loop.

Nested loop- A loop within another loop. (ie. for (k=1; k<=;==k)

For (j=1;j<=3;++j)

Cout<<( k+j) << endl;



Chapter 7
  1. File: A data structure that resides on a secondary storage medium.

  2. Stream: A channel in which data are passed from sender to receiver.

  3. Output Stream: A channel for sending output data.

  4. Input Stream: A channel for receiving input data.

  5. Input File Stream: An input stream that is connected to a file.

  6. Output File Stream: An output stream that is connected to a file.

  7. Abstract: Simplified or partial; hiding detail.

  8. Portable: Able to be transferred to different applications or computers without changes.

  9. Priming Input Statement: An input statement that must be executed before a loop control is tested.

  10. Sequential Search: The process of searching a list by examining the first component and then examining successive components in the order in which they occur.

  11. Buffered File Input: the input of large blocks of data from a file.

  12. Buffer: A block of memory into which data are placed for transmission to a program.

Chapter 8

  1. Array: A data structure whose elements are accessed by means of index positions.

  2. Index: The relative position of the components of an array.

  3. Range Bound Error: The situation that occurs when an attempt is made to use an array index value that is less than 0 or greater than or equal to the size of the array.

  4. Physical Size: The number of memory units available for storing data items in a data structure.

  5. Logical Size: The number of data items actually available in a data structure at a given time.

  6. Selection Sort: A sorting algorithm that sorts the components of an array in either ascending order or descending order. This process puts the smallest or largest element in the top position and repeats the process on the remaining array components.

  7. One-Dimensional Array: An array in which each data item is accessed by specifying a single index.

  8. Two-Dimensional Array: An array in which each data item is accessed by specifying a pair of indices.

Chapter 9 & 10
  1. Struct – a data structure that can have components of different data types.

  2. Classes – a description of the attributes and behavior of a set of computational objects

  3. Procedural Programming – a style of programming that decomposes a program into a set of functions or procedures.

  4. Object-oriented Programming – a style of programming that decomposes a program into a set of communicating objects.

  5. Member – a component of a struct or class.

  • When struct variables are declared, the computer allocates memory for all of the components in both structs. These components are called fields, or members of the struct.

  1. Selector – the operator (.) used to access a member of a struct or class.

    • A selector is formed by placing a period (.) between a struct variable and the name of the member.

  2. Data Abstraction – the separation between the conceptual definition of a data structure and its eventual implementation.

  3. Abstract Data Type (ADT) – consists of a set of values, a defined set of properties of these values, and a set of operations for processing the values.

  4. Encapsulation – the process of hiding and restricting access to the implementation details of a data structure.

  5. Instances – a computational object bearing the attributes and behavior specified by a class.

    • Synonym: object

  6. Attribute – a property that a computational object models, such as the balance in a bank account.

  7. Behavior – the set of actions that a class of objects supports.

    • The first step in developing a new class to solve a problem is to draw up a list of user requirements. These state the attributes and behavior that users expect the class to have.

  8. Formal Specifications – the set of preconditions and post conditions of a function.

  9. Class Declaration Section – an area of a program used to declare the data members and member functions of a class.

  10. Class Implementation Section – an area of a program used tom implement the member functions of a class.

  11. Data Member – a data object within a class declaration module.

  12. Public Member – a data member or member function that is accessible to any program component that uses the class.

    • Public members can be referenced by any module that includes the class library.

  13. Private Member – a data member of member function that is accessible only within the scope of a class declaration.

    • Private members cannot be referenced directly by the users of the class.

  14. Constructor – creates objects of the class.

  15. Accessor – returns the values of the attributes.

  16. Modifiers – modify the values of the attributes.

  17. Default Constructor – a member function that creates and provides reasonable initial values for the data within an object.

  18. Copy Constructor – a member function defined by the programmer and automatically used by the computer to copy the value of objects when they are passed by values to functions.

  19. Const Function – a member function that does not allow changes to the attributes of an abject.

  20. Polymorphism – the property of one operator symbol or function identifier having many meanings.

  21. Overloading – to reuse any built-in operator (or function name, also) to designate and operation on new data types.

  22. 1-Value – a computational object capable of being the target of the assignment statement.

    • A.k.a.TRUE

  23. Software Reuse – the process of building and maintaining software systems out of existing software components.

  24. Server - a computational object that provides service to another computational object.

  25. Client – a computational object that receives a service from another computational object.

  26. Sender - a computational object that requests a service from another computational object.

  27. Receiver – a computational object to which a request is sent for a service.

  28. Base Class – the class form which a derived class inherits attributes and behaviors.

  29. Derived Class – a class that inherits attributes and behavior from other classes.

  30. Free Function – a function not declared within the scope of a class declaration module.

  31. Access Specifier – a symbol that specifies the kind of access that clients have to a server’s data members and member functions.

  32. Protected Member – visible to a derived class, but not visible to any other part of a program.

  33. Vector – a one-dimensional array that provides range checking and can be resized.

  34. Fill Value – a value that is used to initialize every component in a data structure.

  35. Class Template – a kind of class that allows its components types to be specified as parameters.

  36. Pointer Variable – a variable that contains the address of a memory location.

    • Used we cannot predict the size of a data structure.

  37. Dynamic Memory – memory allocated under program control and accessed by means of pointers.

    • This is the memory the programmer can request when it is needed by an application.

  38. Destructor – a member function the returns dynamic memory for an object to the system.

  39. Substring – a string that represents a segment of another string.

  40. Ordered Collection – provides subscript access to just those data locations where elements have been stored.

  41. Sorted Collection – a data structure that behaves like an ordered collection, but the data items are maintained in ascending order.

  42. Access Adjustment – a method of changing the access mode of an inherited member from within a derived class.

    • For Example: a derived class may inherit all members from a base class in protected mode, and then make some members public by means of access adjustments.

  43. Contained Class – a class that is used to define a data member of another class.

  44. Matrix - a two-dimensional array that provides range checking and can be resized.