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 9STE
What output will be produced by the following code, when embedded in a complete
int x = 200;
cout << “Start\n”;
if (x < 100)
cout << “First Output. \n”;
else if (x > 10)
cout << “Second Output. \n”;
else
cout << “Third Output. \n”;
cout << “End\n”;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
5- What is the output for y?
int y = 0;
for (int i = 0; i< 10; ++i)
{
y +=i;
}
cout << y;
Given the snippet of code:
int al = {2, 4, 6, 8, 10, 12), x, *p = a;
x = *(p + 4)+1;
printf("%d", x);
What will be the value of x after the following statement is executed?
13
5
12
11
2) for both triangle and diamond, first display a triangle of requested size, and then
if the choice is a diamond, add the bottom part
3) displays the shape
We want to create a program that draws a diamond or a triangle with a size that the
user selects using a specific character that will be entered at the keyboard. Here are
two examples:
To write this program, we will assume that we have the following functions:
1) void instructions()
// This function describes the program and how it works
A triangle of size 4, using *:
2) int menu()
// This function will return a choice to the main ; 1) draw triangle, 2) draw
diamond, and 3) quit
***
*****
*******
3) draw_shape(int choice)
// This function calls on appropriate function depending on the choice to draw a
shape
A diamond of size 4, using *:
4) int get_size()
// This function will return the size of the shape, same function for either of the
shapes
***
*****
*******
*****
5) char get_char()
// This function will ask users to select a…
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
?.1 Define the different reference meridians that can be used for the direction ofa line.
Elementary Surveying: An Introduction To Geomatics (15th Edition)
What are some of the ways in which welding processes compensate for the inability to meet the conditions of an ...
Degarmo's Materials And Processes In Manufacturing
The solid steel shaft AC has a diameter of 25 mm and is supported by smooth bearings at D and E. It is coupled ...
Mechanics of Materials (10th Edition)
How can user-defined operator overloading harm the readability of a program?
Concepts Of Programming Languages
Assume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in ...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (8th 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
- Print "user_num1 is negative." if user_num1 is less than 0. End with newline. Assign user_num2 with 1 if user_num2 is greater than 12. Otherwise, print "user_num2 is less than or equal to 12.". End with newline. My code: user_num1 = int(input())user_num2 = int(input()) if user_num1 < 0: print("user_num1 is negative.") if user_num2 > 12: user_num2 == 1 else: print("user_num2 is less than or equal to 12.") print('user_num2 is', user_num2) When the input is 0 and 13 my output for user_num2 is 13 and it should be 1. I don't know what I'm doing wrong.arrow_forwardGiven integer napkinsOrdered, output: "Medium carton", if there are 50 - 80 napkins inclusive. "Large carton", if there are 120 - 150 napkins inclusive. End each output with a newline. Ex: If the input is 141, then the output is: Large carton #include <iostream>using namespace std; int main() { int napkinsOrdered; cin >> napkinsOrdered; /* Your code goes here */ return 0;}arrow_forwardwhat is the output of the following code segment? int x = 350; int y = 0; do { y +=x 0; X = x/10; } while (x!=0); cout<arrow_forward
- Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for the given program: Acura made in Japan Fiat made in Italy Tesla made in USA Code writing challenge activity demo 461710 3116374.qx3zqy7 1 car_makers {'Acura': 'Japan', 'Fiat': 'Egypt'} 2 3 # Add the key Tesla with value USA to car_makers 4# Modify the car maker of Fiat to Italy 5 6 "Your solution goes here ''' 7 8 print (f'Acura made in {car_makers ["Acura"]}') 9 print (f'Fiat made in {car_makers ["Fiat"]}') 10 print (f'Tesla made in {car_makers ["Tesla"]}') I =arrow_forwardC - Write a program that takes a first name as the input, and outputs a welcome message to that name.arrow_forward1- What is the output of the following code: k=0;i=0; while(k<1 && i<1) k=k+1; i=i+1;i-i-k; end O i=0, k=1 O i=0, k=0 O i=1, k=0 O i=1, k=1arrow_forward
- In c void f (int *p, int * const q) { p=q *p=3; *p=4; } int i = 1, j =2; int main(){ f(&i, &j); printf("%d %d",i,j); return 0; } a. The program prints 1 2 and terminates b. the program prints 1 3 and 0 c. the program prints 1 4 and terminates d. the program prints 3 4 and terminates e. the program has compiler errorarrow_forwardThe value of a will become 3: int x = 2; x++; int a = (!5 == 5 + 2) ? 3>x ? 3: 5 : 4; cout << x; Select one: O True Falsearrow_forwardYou are required to write a code that requests the user to enter three integer coefficients: a, b, and c in this order. Next, the user is requested to enter the equation degree: 1 for a linear equation and 2 for a quadratic equation. If the user enters an equation degree other than 1 or 2, the program must output Invalid. Based on the equation type, the program will process the coefficients and provide outputs as described below: First Scenario: Linear Equation When a linear equation is selected, the coefficient a is ignored and the equation format becomes: y=bx+c The program should check the slope of the line and accordingly print the values of the x-intercept, the y-intercept, and the line direction with respect to the x-axis each on a separate line. We have four possibilities: Slope is positive (i.e. b > 0): x-intercept = −cb, y-intercept = c, direction is UpwardSlope is negative (i.e. b < 0): x-intercept = −cb, y-intercept = c, direction is DownwardSlope is zero (i.e. b = 0)…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_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
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY