Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Question 1)       The default section is required in a switch statement

Computer Science Feb 03, 2021

Question 1)

   
 

The default section is required in a switch statement. 

     
   
     
  • Question 2

 

   
 

What is the output of the following segment of code if 4 is input by the user when 
asked to enter a number?

int num;
int total = 0;

cout << "Enter a number from 1 to 10: ";
cin >> num;

switch (num)
{
   case 1:
   case 2: total = 5;
   case 3: total = 10;
   case 4: total = total + 3;
   case 8: total = total + 6;
   default: total = total + 4;
}
cout << total << endl;

     
       
  • Question 3

 

   
 

When a program lets the user know that an invalid choice has been made, this is known as: 

     
       
  • Question 4

 

   
 

Which line in the following program will cause a compiler error?

1   #include 
2   using namespace std;
3  
4   int main()
5   {
6      int number = 5;
7  
8      if (number >= 0 && <= 100)
9        cout << "passed.\n";
10    else
11      cout << "failed.\n";
12    return 0;
13  }

     
       
  • Question 5

 

   
 

This is a variable, usually a boolean or an integer, that signals when a condition exists. 

     
       
  • Question 6

 

   
 

What will the following segment of code output if 11 is entered at the keyboard?

int number;

cin >> number;

if (number > 0)
   cout << "C++";
else
   cout << "Soccer";
cout << " is ";
cout << "fun" << endl;

     
 
     
  • Question 7

 

   
 

What will be the output of the following code segment after the user enters 0 at the 
keyboard?

int x = -1;

cout << "Enter a 0 or a 1 from the keyboard: ";
cin >> x;

if (x)
   cout << "true" << endl;
else
   cout << "false" << endl;

     
       
  • Question 8

 

   
 

Given that x = 2, y = 1, and z = 0, what will the following cout statement display?

cout << "answer = " << (x || !y && z) << endl;

     
       
  • Question 9

 

   
 

What is the value of donuts after the following code executes?

int donuts = 10;
if (donuts != 10)
   donuts = 0;
else
   donuts += 2;

     
       
  • Question 10

 

   
 

You should be careful when using the equality operator to compare floating point values 
because of potential round-off errors. 

     
       

 

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment