Question

Complete the following Self-Test exercises (each program should allow the user to enter the data being...

Complete the following Self-Test exercises (each program should allow the user to enter the data being tested as often as the user wishes) In addition to displaying the output, provide a brief explanation as to how the computer arrived at that output.  

What output will be produced by the following code, when embedded in a complete program?

int first_choice = 1;

switch (first_choice + 1)

{

case 1:

cout << "Roast beef\n";

break;

case 2:

cout << "Roast worms\n";

break;

case 3:

cout << "Chocolate ice cream\n";

case 4:

cout << "Onion ice cream\n";

break;

default:

cout << "Bon appetit!\n";

}

Homework Answers

Answer #1
#include <iostream>

using namespace std;
int main()
{
    int first_choice = 1;

    switch (first_choice + 1)
    
    {
    
    case 1:
    
    cout << "Roast beef\n";
    
    break;
    
    case 2:
    
    cout << "Roast worms\n";
    
    break;
    
    case 3:
    
    cout << "Chocolate ice cream\n";
    
    case 4:
    
    cout << "Onion ice cream\n";
    
    break;
    
    default:
    
    cout << "Bon appetit!\n";
    
    }
   
    return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
i want to complete this code to insert a new node in the middle of list...
i want to complete this code to insert a new node in the middle of list (take a node data from user, search the node and insert new node after this node). this is the code #include <iostream> #include <stdlib.h> using namespace std ; struct Node{                int data;                Node *link ;}; struct Node *head=NULL, *tail=NULL; /* pointers to Node*/ void InsertFront(); void InsertRear(); void DeleteFront(); void DeleteRear(); int main(){                int choice;                do{                               cout << "1:...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT