Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 16.1, Problem 4STE
What happens when a throw statement is executed? This is a general question. Tell what happens in general, not simply what happens in the code in Self-Test Question 1 or some other sample code.
1. What output is produced by the following code?
int waitTime = 46; try { cout << "Try block entered.\n"; if (waitTime > 30) throw waitTime; cout << "Leaving try block.\n"; } catch(int thrownValue) { cout << "Exception thrown with\n" << "waitTime equal to " << thrownValue << endl; } cout << "After catch block." << endl; |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the value stored at x, given the statements?
int x;
x = 6 / static_cast<int> (4.5 + 6.4);
Class: Blocks
Write a program that prompts for an integer (that a side length) and displays, using asterisks, a filled and hollow square, placed next to each other. For example if the side length is 5, the program should display:
***** ********** * ****** * ****** * ****** *****
d. student
a, int i = (double)
b. int i = (int)
c. int i = ((int) 4.3* 10)/10.0;
d. int i = 3.4 ;
3:
3.4;
2) Which one is a valid casting?
a. x*=0.5
b. x/=2
3) Given a variable x of type double.
Chapter 16 Solutions
Problem Solving with C++ (10th Edition)
Ch. 16.1 - Prob. 1STECh. 16.1 - What would be the output produced by the code in...Ch. 16.1 - Prob. 3STECh. 16.1 - What happens when a throw statement is executed?...Ch. 16.1 - In the code given in Self-Test Exercise 1, what is...Ch. 16.1 - Prob. 6STECh. 16.1 - Prob. 7STECh. 16.1 - What is the output produced by the following...Ch. 16.1 - What is the output produced by the program in...Ch. 16.2 - Prob. 10STE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I have the code for this one but I do seem to be missing something. This is the question - Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been displayed. This is the code I have. I have got one check right but I can't get the other two - import java.util.*; public class CountByAnything { // Modify the code below public static void main (String args[]) { Scanner input = new Scanner(System.in); final int START; System.out.print("Please enter the value: "); START = input.nextInt(); final int STOP = 500; final int NUMBER_PER_LINE = 10; for(int i = START; i <= STOP; i += START) { System.out.print(i + " "); if(i % NUMBER_PER_LINE == 0) System.out.println(); } } }arrow_forwardnew code can only be entered betwen grey blocks (ie, 17 - 19).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_forward
- Write code that prints: firstNumber ... 2 1Print a newline after each number. Ex: If the input is: 3 the output is: 3 2 1 #include <stdio.h> int main(void) { int firstNumber; int i; scanf("%d", &firstNumber); for(/* Your code goes here */) { printf("%d\n", i); } return 0;}arrow_forwardNot copy. Giving wrong solutions. In all attempt. Downvotearrow_forward• Write a Java program that makes use of two-dimensional array. • Use if-else or switch-case statements. • Apply the corresponding looping statement. Program Specification: 1. Use two-dimensional array with size 7 columns and 5 rows. 2. Seat numbers are populated during run-time and not hard-coded. 3. User is asked to input a seat number. 4. The chosen seat number is replaced by the letter X. 5. Program displays a remark "Seat successfully reserved" when reservation is done. 6. The user is not allowed to reserve a previously reserved seat. Display "Seat is taken" remarks. 7. The user is not allowed to enter an invalid seat number. Display an error message. 8. The program continuously loops. Sample Output: 1 2 3 4 7 8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Enter seat number to reserve: 11 1 3 4 7 8 9. 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Enter seat number to reserve:arrow_forward
- io/courses/1443/quizzes/4601/take/questions/74256 Study the definition of the following two functions "Rate" and "Bonus" and answer the question below. int Rate (int one, int two) { int R = one; for (int i = 0; i 20) num2 num1 * 20 +R; %3D else numl = num2 * 10 + R; return num1 + num2; What is the output of the following code segment? cout << Bonus (3, 5); a hp 近arrow_forwardPF Assignment 3 BS ERP 105903 Submission date: 18th April, 2021 via LMS Assignment should include:Hand Wriiten Coding + Screenshot of Output (a) Create a method GetMax() which takes two integer (int) parameters as an arguments and returns maximal of the two numbers. (b) Write a program that reads three numbers from the console and prints the biggest of them. Use the GetMax() method you just created. Write a test program that validates that the methods works correctly. Write a method that returns the digits of a given decimal number in a reversed order. For example 256, must be printed as 652. Write a program in C to check a given number is positive or negative using method. Write a program that calculates and prints the n! for any n in the range [1…10] number should be taken as input from user through main and should pass as an argument to the method. Write a program in C# Sharp to create a function to input a string and return count of number of spaces are in the…arrow_forward-CLO3- Question No 1: (Array of primitive values) Initialize an array of double values of size 10, with user input. Then calculate and display the sum and average of these values. Question No 2: (Array of objects) Create a class Student having rollno and name as private instance variables. write a program that creates studentArray of five students; it then initializes all students rollno and name by using an input function that will initialize and return an array of five students. and display function that displays the values of all students the array which is passed to it.arrow_forward
- What should be the output from the function below? void display(void) { int i; for(i = 0 ; i <= 5; i++) printf("%d ", i - i * i); }arrow_forwardAthough third multiple choice is longer but still it is a single question 1.) How many times will the following code print "Welcome to Java"? int count = 0; while (count < 10) { System.out.println("Welcome to Java"); Count--; } a. 8 b. 9 c. 10 d. infinity 2.) What will be displayed when the following code is executed? int number = 6; while (number > 0) { number -= 3; System.out.print(number + " "); } a. 6 3 0 b. 6 3 c. 3 0 d. 3 0 -3 e. 0 -3 3.) Which of the following loops correctly computes 1/2 + 2/3 + 3/4 + ... + 99/100? A: double sum = 0; for (int i = 1; i <= 99; i++) { sum = i / (i + 1); } System.out.println("Sum is " + sum); B: double sum = 0; for (int i = 1; i < 99; i++) { sum += i / (i + 1); } System.out.println("Sum is " + sum); C: double sum = 0; for (int i = 1; i <= 99; i++) { sum += 1.0 * i / (i + 1); } System.out.println("Sum is " + sum); D: double sum = 0; for (int i = 1; i <= 99; i++) { sum += i / (i + 1.0); }…arrow_forwardConsider the following code: public static void test_b(int n) { if (n>0) test_b(n-2); System.out.println(n + " "); } What is printed by the call test_b(6)?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License