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 8STE
What is the output produced by the following
#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; } |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
English (e
what is the output of the following program?
#include
int test (int &, int);
main ()
{
int a=10, b=15;
test (b, a);
test (a,b);
cout<
#include <stdio.h>
struct Single
{
int num;
};
void printSingle(int f)
{
int binaryNum[33];
int i = 0;
while(f>0)
{
binaryNum[i] = f % 2;
f = f/2;
i++;
}
for (int j=i-1; j>= 0; j--)
{
printf("%d",binaryNum[j]);
}
}
int main()
{
struct Single single;
single.num = 33;
printf("Number: %d\n",single.num);
printSingle(single.num);
return 0;
}
None
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
- 1. void start() { } A a = new A(); B b = new B(); a.s(b); b = null; /* Line 5 */ a null; /* Line 6 */ System.out.println("start completed"); /* Line 7 */ When is the B object, created in line 3, eligible for garbage collection? after line 5 B after line 6 Cafter line 7 There is no way to be absolutely certain.arrow_forwardWhat the output forthe code fragments? int i = 7; do{ i = i/2; System.out.println(i); } while (i >0);arrow_forward3. a) Examine the following code: int main() { } int pid-fork (); if (pid!=0) { printf ("Wait on child proc \n"); wait (); printf("Done.\n"); }else{ sleep (1); execl ("/bin/ping", "ping","-c", "5", "www.cnn/com", (char*) NULL); execl ("/bin/date", "date", 0, (char*) NULL); } return 0; i) The code compiles and executes, but it does not do what was intended. What does it actually do?arrow_forward
- #include<stdio.h> #include<stdarg.h> void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys", "Cats", "Dogs"); fun2(2, 12, 13, 14); return 0; } void fun1(int num, ...) { char *str; va_list ptr; va_start(ptr, num); str = va_arg(ptr, char *); printf("%s ", str); } void fun2(int num, ...) { va_list ptr; va_start(ptr, num); num = va_arg(ptr, int); printf("%d", num); }.arrow_forwardC# Programming What is the wrong of this code? Can you fix the error on this part? See attached photo for referencearrow_forward#include <stdio.h>#include <limits.h> int findMissingUtil(int arr[], int low, int high, int diff){ if (high <= low)return INT_MAX; int mid = low + (high - low)/2; if (arr[mid+1] - arr[mid] != diff)return (arr[mid] + diff); if (mid > 0 && arr[mid] - arr[mid-1] != diff)return (arr[mid-1] + diff); if (arr[mid] == arr[0] + mid*diff)return findMissingUtil(arr, mid+1, high, diff); return findMissingUtil(arr, low, mid-1, diff);} int findMissing(int arr[], int n){int diff = (arr[n-1] - arr[0])/n; return findMissingUtil(arr, 0, n-1,diff);} int main(){int arr[] = {120001, 120013, 120025, 120037, 120049, 120061,120085,120097,120109,120121};int n = sizeof(arr)/sizeof(arr[0]);printf("The missing element is %d", findMissing(arr, n));return 0;} ______________________________________________________________________________ Convert the code above into Pseudocodearrow_forward
- What is wrong in the following code?arrow_forward// Assume all libraries are included 3 void func (int a, int &b, int &c); // int main () { int i = 5, j = 4, k = 33; 4 7 %3D 8. func (i, j, k); func (j, i, k); cout << j « k << i <« endl; 10 11 12 13 return 0; 14 } // 15 16 void func (int a, int &b, int &c) { 17 18 = 2*c + b; 19 b a; 20 C = a + 3*b; } // 21 22 I|||arrow_forward#include <stdlib.h> #include <time.h> #include <stdio.h> int main(void){ int money_start, bet, money_bet; int money_result; int randomNumber = 0; int n = 0; srand(time(0)); randomNumber = rand() % n; printf("Entering the casino, how much money do you have? "); scanf("%d", &money_start); printf("We are playing roulette, odd or even bets only.\nPlace your bet!"); printf("Enter 1 for odd, 2 for even, 0 to quit: "); scanf("%d", &bet); printf("How much money do you want to bet? "); scanf("%d", &money_bet); while (( bet == 1 || bet == 2 )) { if (( bet == 1)) { printf("You bet $%d on odd numbers.", money_bet); if ((randomNumber % 2 == 0)) { money_result = money_start - money_bet; printf("You lose!"); printf("Your balance is $%d!", money_result);} else { if ((randomNumber…arrow_forward
- // JumpinJive.java - This program looks up and prints the names and prices of coffee orders. // Input: Interactive. // Output: Name and price of coffee orders or error message if add-in is not found. import java.util.Scanner; public class JumpinJive { public static void main(String args[]) throws Exception { // Declare variables. String addIn; // Add-in ordered by customer. final int NUM_ITEMS = 5; // Named constant // Initialized array of add-ins. String addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"}; // Initialized array of add-in prices. double addInPrices[] = {.89, .25, .59, 1.50, 1.75}; boolean foundIt; int x; // Loop control variable. double orderTotal = 2.00; // All orders start with a 2.00 charge // Get user input. Scanner input = new Scanner(System.in); System.out.print("Enter coffee add-in or XXX to quit: "); addIn = input.nextLine();…arrow_forwardPROGRAMMING LANGUAGE: C++ SUBJECT: OOP Task: Find errors in the following code and rewrite a correct version of code with outputs. #include <iostream> using namespace std; class CRectangle { int width. height; public: void set_values (int, int); int area () {return (width * height);} }; void CRectangle::set_values (int a, int b) { width = a; height = b; } int main () { CRectangle a,*b,*c; c= a; a.set_values (1,2); b= new CRectangle; c=&b; c->set_values (3,4); cout << "a area: " << c->area() << endl;// cout << "*b area: " << a.area() << endl;// c->set_values (5,6); cout << "*b area: " << b.area() << endl;// delete b; return 0; }arrow_forward#include using namespace std; int find(int arr[], int value, int left, int right) { int midpt = (left+right)/2; if (left > right) return -1; if ( arr[midpt] return midpt; else if (arr[midpt] < value) == value) return else return find(arr,value, left,midpt-1); } void main(void) { int arr[] ={4,5,6,9,11}; cout<arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License