Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134521176
Author: SAVITCH
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 16.1, Problem 2STE

What would be the output produced by the code in Self-Test Exercise 1 if we make the following change? Change the line

int waitTime = 46;

to

int waitTime = 12;

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;

Blurred answer
Students have asked these similar questions
2) Answer the question with the correct options given below A)What is the output of the following code? int *p1, *p2;   p1 = new int;   p2 = new int; *p1 = 11;   *p2 = 0;   p2 = p1;   cout  << *p1 <<" " << *p2 << endl;    0 11 11 0 0 0 11 11   B) What is wrong with the following code fragment?   int *p1, *p2;  p1 = new int;  p2 = new int;  *p1=11;  *p2=0;  p2=p1;  cout  << *p1 <<" " << *p2 << endl;   delete p1;  delete p2; p1 and p2 both have the same value, so the delete p2 will cause an error nothing B and C You have a memory leak C) Which of the following correctly declares a dynamic array of strings?  p1 = new string[]; p1 = new string[13];  p1 = new string(13);  p1 = new stringArray(13);
I have a question about the following code, why do they have different output, please explain to me.  class Test { private:   int x;   int y; public:   Test(int x = 0, int y = 0) { this->x = x; this->y = y; }   Test &setX(int a) { x = a; return *this; }   Test &setY(int b) { y = b; return *this; }   void print() { cout << "x = " << x << " y = " << y << endl; } };    int main() {   Test obj1(5, 5);      // Chained function calls.  All calls modify the same object   // as the same object is returned by reference   obj1.setX(10).setY(20);      obj1.print();   return 0; }   #include<iostream> using namespace std;    class Test { private:   int x;   int y; public:   Test (int x = 0, int y = 0) { this->x = x; this->y = y; }   Test setX(int a) { x = a; return *this; }   Test setY(int b) { y = b; return *this; }   void print() { cout << "x = " << x << " y = " << y << endl; } };    int main() {   Test obj1;…
Consider the following declaration: int [ ] [ ]  beta  =  new  int  [3] [3]; What is stored in beta after the following executes? Keep track of the variables’ values in a table. BOX IN YOUR OUTPUT RESULT.                     for (int i  = 0; i  <  3; i++)      for (int j  =  0; j  <  3; j++)             beta[ i ] [ j ]  =  2  *  ( i  +  j)  %  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