Concept explainers
What would be the output in Self-Test Exercise 15 if the first line were changed to the following?
int firstChoice = 2;
15. What output will be produced by the following code, when embedded in a complete
int firstChoice = 1;
switch (firstChoice + 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”;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Management Information Systems: Managing The Digital Firm (16th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Mechanics of Materials (10th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- 5- What is the output for y? int y = 0; for (int i = 0; i< 10; ++i) { y +=i; } cout << y;arrow_forwarda. What is wrong in the following code? i. double a = 7.0; int* p = sa; ii. int test = 1; int* pTest = &test; int i = pTest;arrow_forward2- Trace the following code and write the output: class Test1 { Test1(int x) { System.out.println("Test Calls " + x); class Test2 { Testi t1 = new Test1(10); Test2(int i) { t1 = new Test1(i); } public static void main(String[] args) { Test2 t2 = new Test2(5);arrow_forward
- Rewrite the following code segment using the conditional operators (?/:) if (x > y) Z = 1; else z = 20;arrow_forwardJAVA Program ASAP Please modify this program with further modifications which are below so it passes the test cases in Hypergrade. I have provided the failed test cases. 1) For test cases 2 and 3 for the outputted numbers there needs to be commas and there needs to be nothing after that 2)for test case 1 outputted numbers there needs to be nothing after that, 3) for test 4 when file is not found there needs to be nothing after that 4) and for test case 5 and 7 afer a file is not found it needs to display Please re-enter the file name or type QUIT to exit: so you input the text file and displays the numbers. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please…arrow_forwardGiven: an int variable num, an int array current that has been declared and initialized, an int variable aNum that contains the number of elements in the array, an int variable bNum that has been initialized, and a bool variable isNum, Write code that assigns TRUE to isNum if the value of bNum can be found in current, and that assigns FALSE to isNum otherwise. Use only num, current, aNum, bNum, and isNum.arrow_forwardIn c void f (int *p, int * const q) { p=q *p=3; *p=4; } int i = 1, j =2; int main(){ f(&i, &j); printf("%d %d",i,j); return 0; } a. The program prints 1 2 and terminates b. the program prints 1 3 and 0 c. the program prints 1 4 and terminates d. the program prints 3 4 and terminates e. the program has compiler errorarrow_forwardQuestion 2: As a python programmer for an educational institution you are instructed to write a program to simulate the grades for 5 subject areas and display the grade for each based on the following guidelines: Take in the marks of 5 subjects from the user and store it in different variables. 2. Find the average of the marks. 3. Use an else condition to decide the grade based on the average of the marks. 4. Print the Words "Successful Grad Earned" if the student has passed, if the student has failed print the Words" Re-Take Exam" 5. Exit A. Write an algorithm to represent the steps for this program B: Write a program in python to execute the guidelines presented above C. Draw a detailed flowchart to represent the programarrow_forwardGiven the snippet of code: int al = {2, 4, 6, 8, 10, 12), x, *p = a; x = *(p + 4)+1; printf("%d", x); What will be the value of x after the following statement is executed? 13 5 12 11arrow_forwardAnalyze the following program fragment: int x; double d = 4; switch (d) { case 0: x = 1; case 2: x = 2; case 4: x = 3; The program has a compile error because the required default case is missing. The switch control variable cannot be double. The programs compiles and runs fine. The program has a compile error because the break statements are missing..arrow_forwardNo plagiarism pleasearrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education