Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3.2, Problem 5STE
What output will be produced by the following code, when embedded in a complete
int x = 2;
cout << “Start\n”;
if (x <= 3)
if (x ! = 0)
cout << “Hello from the second if.\n”;
else
cout << “Hello from the else.\n”;
cout << “End\n”;
cout << “Start again\n”;
if (x > 3)
if (x ! = 0)
cout << “Hello from the second if.\n”;
else
cout << “Hello from the else.\n”;
cout << “End again\n”;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
//PROBLEM 1/* This program should play a game with the user asking her to guess a target number (randomly generated integer between 1 and 10). The user gets 3 attempts. If she gets it wrong, the program tells her to go up or down, depending on whether her number was less or more then the target. The output may look like this, for example: ============= Guess the number between 1 and 10 in THREE attempts. Enter your first guess: 4 Nope. Go up. Enter your second guess: 6 Nope. Go down. Enter your third and final guess: 5 You got it! CONGRATULATIONS! ============= or like this: ============= Guess the number between 1 and 10 in THREE attempts. Enter your first guess: 4 Nope. Go up. Enter your second guess: 6 Nope. Go up. Enter your third and final guess: 8 GAME OVER! You lost! The number was 9
2. Develop a program which allows the user (Student) to enter three marks. The program
determines the maximum of the three marks and then displays a message based on the
folowing table:
|Range of Marks
Message to be displayed
Enter three marks which are below 70
Got Fail
Enter three marks which are above 90
Got S Grade
Enter three marks which are above 80, but
Got A Grade
less than 91
Enter three marks which are above and
Got B Grade
equal to 70, but less than 81
Maximum mark range is 100
Implement the above program using friend class concept.
The output of the
statement:- x=5; if x =2; disp(x); else;
disp('out of range');
end .. is one of the
-:following
-2
2 O
о о
5
out of range O
LO
Chapter 3 Solutions
Problem Solving with C++ (9th 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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Open the clock-display project and create a ClockDisplay object by selecting the following constructor: new Clo...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
What would be the output in Self-Test Exercise 5 if the assignment were changed to the following? intextra=37;
Absolute Java (6th Edition)
A new class of objects can be created conveniently bythe new class (called the subclass) starts with the charac...
Java How To Program (Early Objects)
What is the total serial transfer time for the eight bits in Figure 1-62? What is the total parallel transfer t...
Digital Fundamentals (11th 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
- 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 11arrow_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_forwardWrite TRUE if the output of the expression is true and FALSE if the output of the expression is false.arrow_forward
- In this game computer chooses a random integer number, and user should guess what is that number through a trial process. You should develop a Java program to conduct this game. The Guessing Game Specification: 1- User specifies a range (from 0 to an upper band) for the game. 2- Program will generate an integer number within the above range as the game answer. 3- Program asks user to enter a guess by printing "Enter a guess" in the console. 4- After user enters a guess: o if the guess is correct, print "Correct! Took 7 guesses to find the answer.", where 7 is the number of guesses as an example. The program should then terminate. o if the guess is greater than the correct value, print "Guess is higher than the answer.". Likewise, for if the guess is less than the correct value. 5- Develop the code based on the provided sample result below. whole code should be within the main method of the Guessing Game01 class. Note: For random integer generation, you should use nextInt() method from…arrow_forwardCode in Java. Instructions attachedarrow_forwardProgram by using C # C sharp My student number :1910206534arrow_forward
- What will be the value of x after the following code is executed? int x = 0; while (x < 50) { x += 20; } 50 20 40 60arrow_forwardC - Write a program that takes a first name as the input, and outputs a welcome message to that name.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_forward
- Analyze the following code: int x = 0;if (x > 0) ;{System.out.println(x);} The code has syntax error. The code has run time error. The value of variable x is always printed because the print statement is not controlled by the if condition. Nothing is printed because x > 0 is false if x = 0.arrow_forwardC Language - Write a program that takes in three integers and outputs the largest value. If the input integers are the same, output the integers' value.arrow_forwardprogram itarrow_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,
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY