



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




What is an increment operator? What does it do? - ++ , it adds one to a variable What does Val++ mean? - val = val+ 1 What is a decrement operator? What does it do? - -- it subtracts one from the variable. It must have a location in memory What does an increment or a decrement operator do in prefix mode? - It increments or decrements and then returns the value to the variable What does an increment or a decrement operator do in the postfix mode? - It returns the value of the variable and then increments or decrements. What is a loop? - A control structure that causes a statement or statements to repeat General format of a while loop - while (expression) statement; Pretest loop - The expression is evaluated before the loop executes. What is the main problems with an infinite loop? - It drains the resources because it makes it too slow. What is a counter, and what is it used for? What must you do before it is in the loop? - A variable that is incremented or decremented each time a loop repeats. Used for controlling. Must be initialized first
What kind of loop is a do while loop? What is required after the expression. - A posttest loop. A semicolon is required. Why are do-while loops executed at least once? - They are a post test loop. It executes and then tests that statement. How long will a do while loop execute? What are they useful for? - Until the expression becomes false. They are useful for menu driven programs to brin user back to menu to make another choice. What are for loops useful for? - for counter controlled loops general format of for loop. - for (initialization; test; update) statement; Is there a semicolon after the update expression? Can you have more then one initialization? - no yes, seperate them with commas, but you can only update one and can have only two semicolons. What will happen if you have a for loop like this for (;;) - Infinite loop, never stops. When do you use a for loop? - In any situation that clearly requires an initialization, a false condition to stop the loop, an update to occur at the end of each iteration. Why won't for (count=11; count <=10; count++) ever initate? - It's a pretest loop and the count is more then 10 already.
What are the steps to open files? - Open file or initialize. use the file (read from, write, or both) close the file (different for different programs. What header file do you need to close and open files? -
How are string literals stored in older C++ - Stored in memory as nul terminated c strings. String objects however, are not. Older ones require you pass the name of the file as a null terminated string, which is known as C-string. ex inputFile.open(filename.c_str()); Example of c_str member function - stringObject.c_str() How do you break a loop? - Can use break to terminate the loop. Use sparingly. How does break work in an inner loop? - terminates the loop only and goes back to the outer loop. Continue statement - Can use to go to the end of a loop to pepare for the next repetition. Use sparingly. What would you use to break two loops at once? - goto