Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 16.1, Problem 9STE

What is the output produced by the program in Self-Test Exercise 8 if the following change were made to the program? Change

sampleFunction(98.6);

in the try block to

sampleFunction(212);

8. What is the output produced by the following program?

#include <iostream>

using namespace std;

void sampleFunction(double test) throw (int);

int main()

{

try

{

cout << "Trying.\n";

sampleFunction(98.6);

cout << "Trying after call.\n";

}

catch(int)

{

cout << "Catching.\n";

}

cout << "End of program.\n";

return 0;

}

void sampleFunction(double test) throw (int)

{

cout << "Starting sampleFunction.\n";

if (test < 100)

throw 42;

}

Blurred answer
Students have asked these similar questions
2- 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);
You are working on problem set: HW2 - loops (Pause) Pause) ? variableScope ♡ Language/Type: Java expressions for % A variable's scope is the part of a program in which it exists. In Java, the scope of a variable starts when it is declared and ends when the closing curly brace for the block that contains it is reached. A variable is said to be in scope where it is accessible. Consider the following program: public class Example { public static void main(String[] args) { performTest (); } } public static void performTest() { int count = 12: for (int i = 1; i <= 12; i++) { runSample(); K } } } System.out.print(count); public static void runSample() { System.out.print("sample"); 7 с M 31 In which of these blocks is the variable count in scope for the entirety of the block? runSample method a. b. main method c. for loop d. O performTest method (order shuffled) In which of these blocks is the variable i in scope for the entirety of the block? a. O main method b. O runSample method c. O…
QUESTION 4 Analyze the following code: public class Test { public static void main (String [] args) { int i = 0; while (i ++ < 10); System.out.println(i + 4); The program compiles despite the semicolon () on the for loop line, and displays 15. The program has a compile error because of the semicolon (;) on the while loop line. The program compiles despite the semicolon (:) on the while loop line, and displays 4.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
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