Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3.2, Problem 6STE
What output will be produced by the following code, when embedded in a complete
int extra = 2;
if (extra < 0)
cout << “small”;
else if (extra = = 0)
cout << “medium”;
else
cout << “large”;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that prompts the user to input five decimal numbers. The program should then add thefive decimal numbers, convert the sum to the nearest integer, and print the result. Use the static_caststatement with an appropriate equation to convert the sum to an integer. Compile and run yourprogram with the following test data:Case 1: Input: 5.1, 5.1, 5.1, 5.1, 5.1. Expected Output: 26.Case 2: Input: 5.0, 5.0, 5.0, 5.0, 5.0. Expected Output: 25.
The language is C++
Consider the following piece of code.
animals = {'a': "ant", 'b': "baboon", 'c': "cat"}
animals['d'] = "donkey"
What will be printed if we execute the following print statement?
print(animals)
Question 9 options:
{'d': "donkey"}
{'a': "ant", 'b': "baboon", 'c': "cat"}
{'a': "ant", 'b': "baboon", 'c': "cat", 'd': "donkey"}
{'a': "ant", 'b': "baboon", 'c': "cat", 'd': "dog"}
What is the output?
#include <stdio.h>
int main(void) {
double dividend = 0.0;
double divisor = 0.0;
printf("%lf\n", dividend / divisor);
dividend = 3.0;
printf("%lf\n", dividend / divisor);
return 0;
}
Question 5 options:
inf
nan
nan
inf
inf
0.0
nan
0.0
Chapter 3 Solutions
Problem Solving with C++ (10th Edition)
Ch. 3.1 - Determine the value, true or false, of each of the...Ch. 3.1 - Name two kinds of statements in C++ that alter the...Ch. 3.1 - In college algebra we see numeric intervals given...Ch. 3.1 - Prob. 4STECh. 3.2 - What output will be produced by the following...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 9...
Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - Write a multiway if-else statement that classifies...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - Prob. 19STECh. 3.2 - Though we urge you not to program using this...Ch. 3.3 - Prob. 21STECh. 3.3 - Prob. 22STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 25STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 27STECh. 3.3 - For each of the following situations, tell which...Ch. 3.3 - Rewrite the following loops as for loops. a.int i...Ch. 3.3 - What is the output of this loop? Identify the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What does a break statement do? Where is it legal...Ch. 3.4 - Write a loop that will write the word Hello to the...Ch. 3.4 - Write a loop that will read in a list of even...Ch. 3.4 - Prob. 38STECh. 3.4 - Prob. 39STECh. 3.4 - What is an off-by-one loop error?Ch. 3.4 - You have a fence that is to be 100 meters long....Ch. 3 - Write a program to score the paper-rock-scissor...Ch. 3 - Write a program to compute the interest due, total...Ch. 3 - Write an astrology program. The user types in a...Ch. 3 - Horoscope Signs of the same Element are most...Ch. 3 - Write a program that finds and prints all of the...Ch. 3 - Buoyancy is the ability of an object to float....Ch. 3 - Write a program that finds the temperature that is...Ch. 3 - Write a program that computes the cost of a...Ch. 3 - (This Project requires that you know some basic...Ch. 3 - Write a program that accepts a year written as a...Ch. 3 - Write a program that scores a blackjack hand. In...Ch. 3 - Interest on a loan is paid on a declining balance,...Ch. 3 - The Fibonacci numbers F are defined as follows. F...Ch. 3 - The value ex can be approximated by the sum 1 + x...Ch. 3 - Prob. 8PPCh. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 13 from Chapter 2 but...Ch. 3 - The keypad on your oven is used to enter the...Ch. 3 - The game of 23 is a two-player game that begins...Ch. 3 - Holy digits Batman! The Riddler is planning his...Ch. 3 - You have an augmented reality game in which you...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Present Value Suppose you want to deposit a certain amount of money into a savings account, and then leave it a...
Starting Out with Java: From Control Structures through Objects (6th Edition)
A_____ is a storage location in memory that is represented by a name. a. mnemonic b. data type c. namespace d. ...
Starting out with Visual C# (4th Edition)
Write a database description for each of the relations shown, using SQL DOL (shorten, abbreviate. or change any...
Modern Database Management
Why are some items within a class designated as private?
Computer Science: An Overview (12th Edition)
What are the advantages in implementing a language with a pure interpreter?
Concepts of Programming Languages (11th Edition)
A(n) _____ is a specialized routine that performs a specific operation and then returns a value.
Starting Out With Visual Basic (7th Edition)
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
- The program down below has a code for a program to play a guessing game with the user. The program should randomly generate an integer between 1 and 10, then ask the user to try to guess the number. If the user guesses incorrectly, the program should ask them to try again until the guess is correct; when the guess is correct, the program should print a congratulatory message. 1. Complete the given program below so that it plays the game as described above. // ************************************************************ // Guess.java // // Play a game where the user guesses a number from 1 to 10 // // ************************************************************ import java.util.Scanner; import java.util.Random; public class Guess { public static void main(String[] args) { int numToGuess; //Number the user tries to guess int guess; //The user's guess Scanner scan = new Scanner(System.in); Random generator = new Random(); //randomly generate the number to guess //print message asking…arrow_forwardConsider the program below. What is the output of the program? If the break statement is replaced with continue statement, what will be the output? Please explain the code. {class hello{public static void Main(string[] args){for (int i = 0; i < 5; i++){if (i == 4){break;} Console.WriteLine ("The number is " + i);Console.ReadLine(); } }}}arrow_forwarda) Consider the following code snippet. {:[" if (aNumber ">=0)xi],[" if (anumber "==0" ) "{]:} system.out.println ("first string") ; else {system.out.println ("sécond string"); 3system.out.println("third string") ; i. What output do you think the code will produce if "aNumber" is 3? [2 marks] ii. Write a test program containing the previous code snippet; make "aNumber" 3. What is the output of the program? Explain why the output is what it is i.e what is the control flow for the code snippet? [4 marks] iii. Using only braces, spaces and line breaks, reformat the oode snippet to make the control flow easier to understand. [3 marks] b) Consider the following class: iv. What are the class variables? [1 mark] Solve wh x=7arrow_forward
- 1) Replace (????) with relevant code for the program to function. Details of the code have been given below. (Java has been used) Show your output. This program should display: 2 -2 3 16 13 11 10 0 -10 */ package finalexamtakehome5; public class Finalexamtakehome5 { // public static void the(int x, int y) { while (x > 0 | y > 0) { x = x - y; y--; System.out.print(x + " "); } System.out.println(y); } // public static void main(String[] args) { theWhile(????); theWhile(20, 4); theWhile(40, -10, 7, 9); } }arrow_forwardWrite a program that takes a first name as the input, and outputs a welcome message to that name. Ex: If the input is: Pat the output is: Hey Pat! Welcome to zyBooks! #include <stdio.h> int main(void) { char userName[50]; scanf("%s", userName); /* Type your code here. */ return 0;arrow_forwardThis is in JAVA. Which expressions for YYY and ZZZ correctly output the indicated ranges? Assume int x's value will be 0 or greater. Choices are in the form YYY / ZZZ. if(YYY){// Output "0-29"} else if (ZZZ) {// Output "30-39"}else {// Output "40+"} A. x < 29 / x >= 29 B. x < 30 / x >= 30 C. x < 30 / x < 40 D. x > 29 / x > 40arrow_forward
- What would be the output of the following program? Question options: 0 1 2 3 4 5 6 7 8 9 None of these optionsarrow_forwardWhat is the output of the following code segment?inte=5,f=10;if(eff0)Write(Purple) inte=5,f=10;if(eff0)Write(Purple) else Write(Gold); Purple Gold PurpleGold nothingarrow_forwardIn your favorite open world adventure video game, currency conversion is as given below: 1 Gold coin 23 Bolts 1 Gem 13 Gold coins Write a program that takes a number of Bolts as user input (as an integer) and converts it to the number of whole Gems, Gold coins, and Bolts as shown below. The conversion information between these measurement metrics is provided in the table above. The number of Bolts should be converted in such a way that maximizes the whole number of Gems and Gold coins. Expected output 1 (bold is user input) Enter the number of Bolts: 32 0 Gems(s) 1 Gold coin(s) 9 Bolt(s) Expected output 2 (bold is user input) Enter the number of Bolts: 3000 10 Gem(s) 0 Gold coin(s) 10 Bolt(s) The file should be named as convertCurrency.cpp. Don’t forget to head over to Coderunner on Canvas and paste your solution in the answer box!arrow_forward
- Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 #include <stdio.h> int main(void) { /* Type your code here. */ return 0; }arrow_forwardWhat is the output of the following (when embedded in a complete program)? if (12<12) cout << “Never”; else cout << “Always”;arrow_forwardSuppose x, y, z, and w are int variables. What value is assigned to each of these variables after the last statement executes? x = 7; y = 2 * x - 3;z = x + y - 3; x = z / y;y = z - x;w = x + y + 2 * z;w--;y = 2 * w + z - x;arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY