COSC 1436 EXAM QUESTIONS AND ANSWERS
Something within a while loop must eventually cause the condition to become false, or a(n) ________ results. - Answer-infinite loop
True/False: A while loop is somewhat limited, because the counter can only count up, not down. - Answer-false
A file ___...
COSC 1436 EXAM QUESTIONS AND
ANSWERS
Something within a while loop must eventually cause the condition to become false, or
a(n) ________ results. - Answer-infinite loop
True/False: A while loop is somewhat limited, because the counter can only count up,
not down. - Answer-false
A file __________ is a small holding section of memory that file-bound information is
first written to - Answer-buffer
int number = 6
int x = 0:
x = -- number;
cout << x << endl; - Answer-5
True/False: the scope of a variable declared in a for loop's initialization expression
always extends beyond the body of the loop - Answer-false
The while loop has two important parts: an expression that is tested for a true or false
value, and: - Answer-a statement or block that is repeated as long as the expression is
true
True/False: In C++ you can pass a string object as argument to a file stream object's
open member function - Answer-True
The statement in the body of a while loop may never be executed, whereas the
statements in the body of a do-while loop will be executed: - Answer-at least one
True/false: string objects have a member function named c_str that returns the contents
of the object formatted as a null-terminated C-string - Answer-true
n = 1;
for ( ; n <=5; )
cout << n << ' ' ;
n++; - Answer-1 1 1 ..... and on forever
What will the following code display?
Int number = 6;
Cout << number++ << endl; - Answer-6
How many times will the following loop display "Hello"?
, for (int i = 20; i >0; i --)
cout << "Hello!" << endl; - Answer-20
This is a variable that is regularly incremented or decremented each time a loop
iterates. - Answer-counter
This is a special value that marks the end of a list of values. - Answer-sentinel
What will the following code display?
Int number = 6;
number++;
Cout << number << endl; - Answer-7
If you want a user to enter exactly 20 values, which loop would be the best to use? -
Answer-for
int number = 6
++number;
cout << number << endl; - Answer-7
True/False: the update expression of a for loop can contain more than one statement,
e.g. counter++ - Answer-true
This statement may be used to stop a loop's current iteration and begin the next one -
Answer-continue
True/False the increment and decrement operators can be used in mathematical
expressions; however, they cannot be used in relational expressions - Answer-False
This is a statement that causes a function to execute. - Answer-function call
The value in this type of local variable persists between function calls. - Answer-static
Which of the following statements about global variables is true? - Answer-A global
variable can have the same name as a variable that is declared locally within a function
Look at the following function prototype
int myFunction(double);
what is the data type of the function's parameter variable? - Answer-double
True/False: One reason for using functions is to break programs into manageable units,
or modules - Answer-true
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Scholarsstudyguide. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.49. You're not tied to anything after your purchase.