COSC 1436 Practice Test Questions and Answers All Correct
6 views 0 purchase
Course
COSC 1436
Institution
COSC 1436
COSC 1436 Practice Test Questions and Answers All Correct
Which of the following will cause a logical error if you are trying to compare x to 5?
a. if (x == 5)
b. if (x = 5)
c. if (x <= 5)
d. if (x >= 5) - Answer-b. if (x = 5)
The appearance of = in place of == resembles a(n) __ .
a...
COSC 1436 Practice Test Questions
and Answers All Correct
Which of the following will cause a logical error if you are trying to compare x to 5?
a. if (x == 5)
b. if (x = 5)
c. if (x <= 5)
d. if (x >= 5) - Answer-b. if (x = 5)
The appearance of = in place of == resembles a(n) __ .
a. syntax error
b. silent killer
c. compilation error
d. input failure - Answer-b. silent killer
The conditional operator ? : takes __ arguments.
a. two
b. three
c. four
d. five - Answer-b. three
What is the value of x after the following statements execute?
int x;
x = (5 <= 3 & & 'A' < 'F') ? 3 : 4
a. 2
b. 3
c. 4
d. 5 - Answer-c. 4
Assume you have three int variables: x = 2, Y = 6 , and z. Choose the value of z in the
following expression:
z = ( y / x > 0) ? x : y;
a. 2
b. 3
c. 4
d. 6 - Answer-a. 2
What is the output of the following code?
char lastlnitial = 'S';
switch (lastlnitial) {
case 'A': cout « "section 1" «endl; break;
case 'E': cout « "section 2" «endl; break;
, case 'C': cout « "section 3" «endl; break;
case 'D': cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 2
b. section 3
c. section 4
d. section 5 - Answer-d. section 5
What is the output of the following code?
char lastlnitial = 'A';
switch (lastlnitial) {
case 'A': cout « "section 1" «endl; break;
case 'E': cout « "section 2" «endl; break;
case 'C': cout « "section 3" «endl; break;
case 'D': cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 1
b. section 2
c. section 3
d. section 5 - Answer-a. section 1
What is the output of the following code fragment if the input value is 4?
int num; int alpha = 10;
cin » num;
switch (num) {
case 3: alpha++; break;
case 4:
case 6: alpha = alpha + 3;case 8: alpha = alpha + 4; break;
default: alpha = alpha + 5; }
cout « alpha « endl;
a. 13
b. 14
c. 17
d. 22 - Answer-a. 13
What is the output of the following C++ code?
int x = 55; int y = 5;
switch (x % 7) {
case 0:
case 1: y++;
case 2:
case 3: y = y + 2;
case 4: break;
case 5:
case 6: y = y - 3; }
cout « y « endl;
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.09. You're not tied to anything after your purchase.