Computer Science > CASE STUDY > Final Study Guide CSE 100[100% (All)
3.7 To use the combined assignment operators: +=, -=, *=, /=, and %=. In general, an expression such as x = x operator expr is equivalent to writing x operator= expr. For example, in x = x % (a + b) ... the operator is % and expr is (a + b). Consequently, this expression is equivalent to writing x %= (a + b). 5.1 To use the ++ increment and -- decrement operators to add or subtract one to or from an integer variable. 5.2 While loop – The condition expression is tested and if it is true each statement in the body of the loop is executed. Then the conditions tested again. If it is still true each statement is executed again, this cycle repeats until the condition is false. As with an if statement, each statement in the body to conditionally executed ends with the semicolon, but there is no semicolon after condition expression in the parentheses. As with an if statement, when the body of the loop contains, two or more statements, these statements must be surrounded by braces. The while works like an if statement that can execute over and over. As long as he expression in the parentheses is true, the conditionally executed statements will repeat. Body of the loop contains one or more C++ statements. The execution of the body is called a pass. The six relational operators and their precedence levels – Relational operators – allow you to compare numeric and char values and determine whether one is greater than, less than, equal to, or not equal to another. > greater than, < less than, >= greater than or equal to, <=less than or equal to, ==equal to, != not equal to. All the relational operators are binary operators with left to right associativity. Relational operators are binary which means they use two operands. Relational expressions are Boolean expressions, which means their value can only be true or false. The == operator determines whether the operand on its left is equal to the operand on its right. Infinite loop – if a loop does not have a way of stopping. It keeps repeating until the program is interrupted. 5.4,5.6 counter variable is a variable that is regularly incremented or decremented each time a loop iterates. The for loop is a pretest loop that combines the initialization, testing, and updating of a loop control variable in a single loop header. The first line of the for loop is the loop header. After the key word for, there are 3 expressions inside the parenthesis, separated by semi-colons. The first expression is the initialization expression. It is typically used to initialize a counter to its starting value. This is the first action performed by the loop. It is only done once. The second expression is the test expression. It tests a condition in the same way the test expression in the while and do-while loop does, and controls the execution of the loop. As long as this condition is true, the body of the for loop will repeat. The for loop is pretest loop, so it evaluates the test expression before each iteration. The third expression is the update expression. It executes at the end of each iteration. Typically, this is a statement that increments the loop’s counter variable. A conditional loop executes as long as the particular condition exists. A loop that repeats a specific number of times, is knows as a count-controlled loop. It must posses 3 elements: 1. It must initialize the counter variable to a starting value. 2. It must test the counter variable by comparing it to a final value. When the counter variable reached its final value, the loop terminates. 3. It must update the counter variable during each iteration. This is usually done by incrementing the variable. Counting loop – starts from a particular integer and goes up or down depending on the condition. In a for or while loop a control variable can be incremented (i++, ++i, i = i + 1, i += 1), decremented (i--, --i, i = i - 1, i -=1), or changed by more than one (e.g., i = i + 2, i += 3, i -= 5), during each pass of the loop. 5.7 Running sum loop-A running total is a sum of numbers that accumulates with each iteration of a loop. The variable used to keep the running total is called an accumulator. Programs that add a series of numbers typically used two elements: 1. A loop that reads each number in the series 2. A variable that accumulates the total of the numbers, as they are read. It is often said that the loop keeps a running total because it accumulated the total as it reads each number in the series. 5.8 Sentinel is a "special" value that marks the end of a list of values and is different than the values in a list; it must "stand out". A sentinel loop is a loop that goes on until it hits a predetermined value. 5.9 End of file loop reads values from a file until the "end of the file" is reached. An input stream object (such as cin or fin) acts as a boolean variable when written as a conditional expression in an if statement or loop. If the stream is not in the failed state, then it evaluates to true. If the stream has failed (e.g., because we tried to read past the end of file) then it evaluates to false. This is why while (fin >> value) { ... } works for reading a list of values from a file. 5.11 Nested loop – it is a loop that is inside another loop. The first loop is called the outer loop and the one nested inside is called the inner loop. They are used when, for each iteration of the outer loop, something must be repeated a number of times. The inner loop will go through all its iterations each time the outer loop is executed. Any kind of loop can be nested within any other kind of loop. 5.12 The break statement will cause a loop to immediately terminate, i.e., when break is encountered, you will immediately drop out of the loop. 7.1 Writing a class is sort of like creating a programmer-defined data type. An object is an instance of class. When an object is defined by writing Classname objname; we say objname is being instantiated (or created). A class declaration specifies two things: data members and function members. The data members and function members are said to be encapsulated in the object. Data members should always be declared as private and that this is known as information hiding. Data members store data and function members manipulate data members. 7.3 Class declaration – the class is a construct primarily use to create objects, it is a programmer defined data type that describes when an object of the class will look like when it is created. IT consists of the set of variables and a set of functions. Private and public are called access specifiers because they designate who can access the various members of the class. Each access specifier is followed by colon. A public member variable can be access by functions outside the class and a public member function can be called by function outside the class. A private member variable can only be accessed by function that is a member of the same class and a private member function can only be called by other function that are member of the class. The default settings are set to private. 7.4 An object is an instance of a class. Defining a class object is called the instantiation of the class. One class declaration/definition is written, but many objects of that class can be instantiated. Public members of a class object are accessed with a dot operator for example – circle1.setRadius(1);. Accessor function is function that uses the value of a class variable but does not change it. Also called get function or getter functions. Mutator function is a function which stores a value in member variable or changes it value. Also called set functions or setter functions. 7.5 Class member functions are defined similarly to regular functions. They have a function header that includes return type (which may be void), a function name, and a parameter list, (which may be possibly empty). This statements that carry out the actions of the function are contained within the pair for braces that follow the function header. The :: symbol is called the scope resolution operator. it is needed to indicate that these are class member functions to tell the compiler which class do they belong to. Accessor functions often start with the prefix Get and mutator functions with Set. 7.6 A constructor is a member function that is automatically called when a class object is created. IT looks like a regular function, except its name must be the same as the name of the class it is a part of. This is how the compiler knows that a particular member function is a constructor. Also, it must have no return type. Constructors never return a value and no return value data type is specified. Constructors can be overloaded and how the compiler determines which one to call based on the signature of theConstructor call and the signatures of the constructors. The default constructor is the one that is called with no actual parameters. The default constructor is the one that is called when an object is instantiated by writing Classname objname; 7.8 A private function member is one that can only be called by other functions of the class. Function members should be private unless they have to be public. 7.9 Objects can be passed as parameters to a function, either by-value or by-reference. Objects are usually passed by-reference because it is usually faster to do it this way. Just as a function can be written, to return an int, string, double or other data type, they can also be design to return an object. The function normally creates a local instance of the class, sets its data members, and then returns it. 7.10 A class data member can be an object of another class. This is called object composition. A data member is an object, know how to call the accessor/mutator functions to read/write the object's data members. T [Show More]
Last updated: 3 years ago
Preview 1 out of 4 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Apr 20, 2021
Number of pages
4
Written in
All
This document has been written for:
Uploaded
Apr 20, 2021
Downloads
0
Views
120
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·