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
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.
What will be the value of x after the following code is executed?
int x = 0;
while (x < 50)
{
x += 20;
}
50
20
40
60
You 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)…
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
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 (6th Edition)
Add syntax diagrams to those in Question 5 of Section 6.4 to obtain a set of diagrams that defines the structur...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Define gators to be an empty vector of ints and snakes to be a 10-element vector of double s. Then write a stat...
Starting Out with C++: Early Objects
Write a cout statement that uses stream manipulators to display the contents of the variable divSales in a fiel...
Starting Out with C++: Early Objects (9th Edition)
What is denormalization?
Database Concepts (7th Edition)
Answer question 3.33, but do not consider any pet having the breed of Unknown.
Database Concepts (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
- 6. Which of the below code contains correct overloading code? Why would the other won't work? Code 1 double myMultiply. (int x){ return 10 x; Code 2 int awMultielx (int x){ return 10 x; } double yMultirly. (double x){ double yMultiely (int x){ return 20 x; return 2e * x; 7. What would be the output for the following program and why ( explain in short): Bublis static void nain(String acsal))( String."; String si - "Testing Java Program String s2 - sukstriui13); 8. Write the code in Java for the following class from the UML diagram below: Vehicle -passengers: int -maxSpeed: double -color: String +Vehiclelint,double.String) +setColor(): void +getColor(): String +findCaracityl): double The findCapacityl) method return the capacity of the vehicle by the following formula: Capacity = passengers * 75 L0.20 * maxSpeed)arrow_forwardUser Prompts Your program will allow a human user to play Rock, Paper, Scissors with the computer. At the beginning of the game, the user should be prompted for his/her input. The valid choices for input are:• R or r (Rock)• P or p (Paper)• S or s (Scissors)• Q or q (Quit) Beginning of Round At the beginning of each round your program should ask the user for an input. Invalid Entry If the user inputs something other than r, R, p, P, s, S, q or Q, the program should detect the invalid entry and ask the user to make another choice. Round structure Each round of the game will have the following structure:1. The program will choose a weapon (Rock, Paper, Scissors), but its choice will not be displayed until later so the user doesn’t see it.2. The program will announce the beginning of the round and ask the user for his/her weapon choice3. The two weapons will be compared to determine the winner (or a tie) and the results will be displayed by the program4. The next round will…arrow_forwardAlert dont submit AI generated answer.arrow_forward
- Given: char newFunc(int & a, int b) { char output = 'Q'; %3D while (aarrow_forward#include <stdio.h> int main(){ int M; printf("Enter the number of chairs you want to enter:\n"); scanf("%d", &M); double price[M]; double sum = 0.0; int i=0; while(i < M) { printf("Enter price of chair #%d: ",(i+1)); scanf("%lf", &price[i]); if(price[i] < 1003) { price[i] = price[i] - price[i] * 0.10; sum = sum + price[i]; } else if(price[i] >= 1003 && price[i] <= 2006) price[i] = price[i] - price[i] * 0.15; else if(price[i] > 2006) price[i] = price[i] - price[i] * 0.20; printf("Price of chair #%d after discount is %.3lf\n", (i+1), price[i]); i++; } printf("\n\nTotal price after discount of all chairs which got a discount of 10%% is "); printf("%.3lf", sum); int N = 2; printf("\n\nN is equal to the sum of My EUI ID(1+1) = 2"); double p[N]; printf("\nEnter price of %d desks: ",…arrow_forward11arrow_forwardjava please Create 2 functions that returns the hundreds andthousands digit from aninteger.int thousandsDigit(int a); // Ex, thousandsDigit(1234) => 1int tensDigit(int a); // Ex, tensDigit(1234) => 3//Use the % operator to return the tenth and thousandth value. %10 and%1000Create a function that counts the number of digits in a positive integer.int countDigits(int a); // Ex, countDigits(1234)=> 4//Convert an integer to String and then returns its length.arrow_forwardProgramming Language: Java Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade. NOTE: MUST ADD COMMENTSarrow_forwardWhich ones of these statements are correct and why?arrow_forwardH7.arrow_forwardWrite a statement that assigns finalValue with the multiplication of userNum1 and userNum2. Ex: If userNum1 is 6 and userNum2 is 2, finalValue is 12. let userNum1 = 6; // Code tested with values: 6 and 4let userNum2 = 2; // Code tested with values: 2 and -2 let finalValue = 0;arrow_forward47. IF a>=10 && B<=5 Then some line of code Write down the test case for this?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
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