Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Question 1)       The default section is required in a switch statement

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

Computer Science

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. 

     
       

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE