Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
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
*68. What is the return value of f (p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value. int f(int &x, int c) { c = c 1; if X = X + 1; return f(x, c) } (a) 3024 (c==0) return 1; * X; (b) 6561 (c) 55440 (d) 161051
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);
..• 6. Modify the following program so that it terminates, printing "Invalid input" as soon as an invalid input is detected. If both inputs are valid, print their product. Test.java ebook-bjlo-2-ch03-sec08-cc-1ava.util.Scanner; 2 3 public class Test 4 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter an integer: "); in.nextInt(); 9. 10 int m = 11 System.out.print("Enter another integer: "); 12 int n = in.nextInt(); 13 System.out.println("Product: " + m * n); 14 15 } CodeCheck Reset
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