Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5.3, Problem 5.3CP
What will each of the following
A) x = 2;
y = x++;
cout << x << " " << y;
B) x = 2;
y = ++x;
cout << x << " " << y;
C) x = 2;
y = 4 ;
cout << x++ << " " << − −y;
D) x = 2;
y = 2 * x++;
cout << x << " " << y;
E) x = 99;
if (x++ < 100)
cout "It is true! \n";
else
cout << "It is false! \n";
F) x = 0;
if (++x)
cout << "It is true! \n";
else
cout << "It is false! \n";
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Determine all the output from the following program as it would appear on the
screen.
void func1(int);
void func2(int = 4, int = 5, int = 2);
int func3(int &, int, int);
%3D
int main()
{
int x = 0, z = 0, y = 2;
func1(y);
cout << y << endl;
func2(x, y, z);
func2();
func3(x, y, z);
= Z
func1(x);
cout << x << " " << y << " " << z << endl;
return 0;
}
void func1(int b)
{
static int a;
Pls debug this code and create a flow chart
change normal body temperature to 36.5–37.5 °C
#include<iostream>using namespace std;int main(){
float temp;cout<<"Enter the body temperature in Celsius\n";cin>>temp;if (temp>=37){cout<<"The quarantine of the patient is required\n";cout<<"Enter the name of the patient\n";string patient;cin>>patient;cout<<"Where the passenger is from\n";string place;cin>>place;cout<<patient<<" from "<<place<<"is to be quarantined at Hospital";
}cout<<"Normal temperature\n";}
Chapter 5 Solutions
Starting Out with C++: Early Objects
Ch. 5.1 - How many lines will each of the following while...Ch. 5.1 - Prob. 5.2CPCh. 5.3 - What will each of the following program segments...Ch. 5.5 - Prob. 5.4CPCh. 5.5 - Write a program segment with a do-while loop that...Ch. 5.5 - Revise your answer to Question 5.8 to use the...Ch. 5.6 - What three expressions appear inside the...Ch. 5.6 - You want to write a for loop that displays I love...Ch. 5.6 - Prob. 5.9CPCh. 5.6 - Write a for loop that displays your name 10 times.
Ch. 5.6 - Write a for loop that displays all of the odd...Ch. 5.6 - Write a for loop that displays every fifth number,...Ch. 5.8 - Prob. 5.13CPCh. 5.8 - Write a for loop that sums up the squares of the...Ch. 5.8 - Write a for loop that sums up the squares of the...Ch. 5.8 - Write a for loop that repeats seven times, asking...Ch. 5.8 - Write a for loop that calculates the total of the...Ch. 5.8 - Prob. 5.18CPCh. 5.8 - Write a sentinel-controlled while loop that...Ch. 5.11 - Which loop (while, do-while, or for) is best to...Ch. 5.11 - How many total stars will be displayed by each of...Ch. 5.11 - What will the following program segment display?...Ch. 5.12 - Prob. 5.23CPCh. 5.12 - What header file must be included in a program to...Ch. 5.12 - What five steps must be taken when a file is used...Ch. 5.12 - What is the difference between a text file and a...Ch. 5.12 - Prob. 5.27CPCh. 5.12 - What type of file stream object do you create if...Ch. 5.12 - What type of file stream object do you create if...Ch. 5.12 - Prob. 5.30CPCh. 5.12 - Assume you have an output file named numbers.txt...Ch. 5 - To _______ a value means to increase it by one.Ch. 5 - To _______ a value means to decrease it by one.Ch. 5 - Prob. 3RQECh. 5 - Prob. 4RQECh. 5 - The statement or block that is repeated is known...Ch. 5 - Each repetition of a loop is known as a(n)...Ch. 5 - A loop that evaluates its test expression before...Ch. 5 - A loop that evaluates its test expression after...Ch. 5 - A loop that does not have a way of stopping is...Ch. 5 - A(n) ______ is a variable that counts the number...Ch. 5 - Prob. 11RQECh. 5 - A(n) ________ is a variable that is initialized to...Ch. 5 - A(n) ______ is a special value that marks the end...Ch. 5 - The ________ loop is ideal for situations that...Ch. 5 - The _____ loop always iterates at least once.Ch. 5 - The _______and ______ loops will not iterate at...Ch. 5 - Inside the for loops parentheses, the first...Ch. 5 - A loop that is inside another is called a(n)...Ch. 5 - The _________ statement causes a loop to terminate...Ch. 5 - The _____ statement causes a loop to skip the...Ch. 5 - What header file do you need to include in a...Ch. 5 - What data type do you use when you want to create...Ch. 5 - What happens if you open an output file and the...Ch. 5 - What data type do you use when you want to create...Ch. 5 - What is a files read position? Where is the read...Ch. 5 - What should a program do when it is finished using...Ch. 5 - Write code that lets the user enter a number. The...Ch. 5 - Write a do-while loop that asks the user to enter...Ch. 5 - Write a for loop that displays the following set...Ch. 5 - Write a loop that asks the user to enter a number....Ch. 5 - Write a nested loop that displays the following...Ch. 5 - Write a nested loop that displays 10 rows of #...Ch. 5 - Rewrite the following code, converting the while...Ch. 5 - Rewrite the following code, replacing the do-while...Ch. 5 - Convert the following whi1e loop to a for loop:...Ch. 5 - Convert the following for loop to a while loop:...Ch. 5 - Prob. 37RQECh. 5 - Prob. 38RQECh. 5 - What will each of the following program segments...Ch. 5 - int x = 1 ; while (x 10) x++; cout x;Ch. 5 - Prob. 41RQECh. 5 - Prob. 42RQECh. 5 - Each of the program segments in this section has...Ch. 5 - A) // This code should use a loop to raise a...Ch. 5 - A) // This code should display the sum of two...Ch. 5 - Prob. 46RQECh. 5 - Characters for the ASCII Codes Write a program...Ch. 5 - Sum of Numbers Write a program that asks the user...Ch. 5 - Distance Traveled The distance a vehicle travels...Ch. 5 - Celsius to Fahrenheit Table In one of the Chapter...Ch. 5 - Prob. 5PCCh. 5 - Ocean Levels Assuming the level of the Earths...Ch. 5 - Pennies for Pay Write a program that calculates...Ch. 5 - Prob. 8PCCh. 5 - Prob. 9PCCh. 5 - Random Number Guessing Game Write a program that...Ch. 5 - Random Number Guessing Game Enhancement Enhance...Ch. 5 - The Greatest and Least of These Write a program...Ch. 5 - Prob. 13PCCh. 5 - Prob. 14PCCh. 5 - Population Write a program that will predict the...Ch. 5 - Math Tutor Version 3 This program started in...Ch. 5 - Hotel Suites Occupancy Write a program that...Ch. 5 - Rectangle Display Write a program that asks the...Ch. 5 - Diamond Display Write a program that uses nested...Ch. 5 - Triangle Display Write a program that uses nested...Ch. 5 - Arrowhead Display Write a program that uses nested...Ch. 5 - Sales Bar Chart Write a program that asks the user...Ch. 5 - Savings Account Balance Write a program that...Ch. 5 - Using FilesTotal and Average Rainfall Write a...Ch. 5 - Using FilesPopulation Bar Chart Write a program...Ch. 5 - Using FilesStudent Line Up Modify the Student...Ch. 5 - Using FilesSavings Account Balance Modification...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
This is the last index in a list. a. 1 b. 99 c. 0 d. The size of the list minus one
Starting Out with Python (3rd Edition)
Bond Yield One measure of a bond's performance is its Yield To Maturity (YTM). YTM values for government bonds ...
Introduction To Programming Using Visual Basic (11th Edition)
Suppose a multiprogramming operating system allocated time slices of 10 milliseconds and the machine executed a...
Computer Science: An Overview (12th Edition)
Add methods to the Person class from Self-Test Question 16 to perform the following tasks: Set the name attribu...
Java: An Introduction to Problem Solving and Programming (8th Edition)
What is denormalization?
Database Concepts (7th Edition)
Write cout statements with stream manipulators that perform the following: A) Display the number 34.789 in a fi...
Starting Out with C++ from Control Structures to Objects (9th 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
- #include <stdio.h>#include <stdlib.h> int cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //Function definitionvoid calculateChange(int change) {if(change > 0) {if(change >= 50) {change -= 50;cent50++;} else if(change >= 20) {change -= 20;cent20++;} else if(change >= 10) {change -= 10;cent10++;} else if(change >= 05) {change -= 05;cent05++;}calculateChange(change);}} //Define the functionvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50); if(cent20)printf("\n20 Cents : %d coins", cent20); if(cent10)printf("\n10 Cents : %d coins", cent10); if(cent05)printf("\n05 Cents : %d coins", cent05); cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //Function's definitionint TakeChange() { int change;printf("\nEnter the amount : ");scanf("%d", &change);return change; }//main functionint main() {//call the functionint change = TakeChange(); //use while-loop to repeatedly ask for input to the userwhile(change != -1){if((change %…arrow_forward#include <stdio.h>#include <stdlib.h> int cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //Function definitionvoid calculateChange(int change) {if(change > 0) {if(change >= 50) {change -= 50;cent50++;} else if(change >= 20) {change -= 20;cent20++;} else if(change >= 10) {change -= 10;cent10++;} else if(change >= 05) {change -= 05;cent05++;}calculateChange(change);}} //Define the functionvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50); if(cent20)printf("\n20 Cents : %d coins", cent20); if(cent10)printf("\n10 Cents : %d coins", cent10); if(cent05)printf("\n05 Cents : %d coins", cent05);cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //Function's definitionint TakeChange() { int change;printf("\nEnter the amount : ");scanf("%d", &change);return change; }//main functionint main() {//call the functionint change = TakeChange(); //use while-loop to repeatedly ask for input to the userwhile(change != -1){if((change %…arrow_forward#include <stdio.h>#include <stdlib.h> int cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //Function definitionvoid calculateChange(int change) {if(change > 0) {if(change >= 50) {change -= 50;cent50++;} else if(change >= 20) {change -= 20;cent20++;} else if(change >= 10) {change -= 10;cent10++;} else if(change >= 05) {change -= 05;cent05++;}calculateChange(change);}} //Define the functionvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50); if(cent20)printf("\n20 Cents : %d coins", cent20); if(cent10)printf("\n10 Cents : %d coins", cent10); if(cent05)printf("\n05 Cents : %d coins", cent05);cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //Function's definitionint TakeChange() { int change;printf("\nEnter the amount : ");scanf("%d", &change);return change; }//main functionint main() {//call the functionint change = TakeChange(); //use while-loop to repeatedly ask for input to the userwhile(change != -1){if((change %…arrow_forward
- computer programmingarrow_forwardMP: Create a program using structures to compute for the final grade of a student with the following conditions; Prelim grade 30% Midterm grade 30% Finals grade 40% See screenshot below for your reference: Name: Juan Dela Cruz Prelim Grade: 89 Midterm Grade: 82 Finals Grade: 77 Student Name Final Grade : Juan Dela Cruz 82.10 Name: Bill Gates Prelim Grade: 77 Midterm Grade: 84 Finals Grade: 90 Student Name Final Grade : Bill Gates 84.30arrow_forwardC++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_forward
- Programming Assignment Create a program application using C#, C++, or your preferred software for a small Employee Payroll system using one dimensional arrays. Include the following for at least 5 employees for a period of 3 months (assume the employees are paid monthly) a. hourly wages b. monthly earnings c. annual earnings d. monthly deductions (look the basic deductions) e. annual deductions f. net pay g. gross payarrow_forward2) 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…arrow_forward1- You are required to draw flow chart and write a Pseudocode for the following problem statement. Muscat MobiCare is a Mobile Outlet, which provides Mobile repair services. The charges of mobile repairs are based on the type of the service. Details of charges are as follow: Software Fault: 4 OMR Screen Fault: 6 OMR Network/Wi-Fi Fault: 8 OMR Internal Hardware Fault: 10 OMR The Outlet offers discount to the loyal customers. The discount is offered based on the customer visits to the outlet. Following is the detail of discounts. 1- Customer visiting 4 times a year gets 20% discount. 2- Customer visiting 6 times a year gets 30% discount. 3- Customer visiting 8 times a year gets 50% discount. You are required to draw a Flow Chart diagram and write a Pseudocode for a computer program that takes customer name, mobile model, visit date, total number of visits, and required service (mentioned above). The program outputs a receipt with all the entered information plus repair charges based on…arrow_forward
- main.c diy.h 1. DIY Pattern(from codeChum, modified) 1 #include 2 #include"diy.h" by Catherine Arellano int main(void) { getNum(); getNum(); getNum (); getNum(); display(n1,n2, n3,n4); 3 4 int n1 = Step right up and create the pattern! Whoever gets all patterns right will be crowned the new King of Patterns and gets to brag about it to their friends. Here are the instructions: you will be given 4 int n2 int n3 7 int n4 8 numbers; each number corresponds to the amount 9 return 0; of times a symbol is repeated in the pattern. That's 10 pretty much it. Good luck! Symbols: n1 = # n2 = \ n3 = / n4 = - %3D Implement the following functions: int getNum(); *accepts input from the user.*/ void display(int n1, int n2, int n3, int n4); /*displays the given pattern*/arrow_forwardPython XYZ store plans to give a festival discount to its customers. The store management has decided to give discount on the following criteria: Shopping Amount Discount Offered >=500 and <1000 5% >=1000 and <2000 8% >=2000 10% An additional discount of 5% is given to customers who are the members of the store. Create a program using user defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions:Net Payable Amount = Total Shopping Amount – Discount.arrow_forwardIn cengage mindtap The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of 12%. Monthly payments are 5% of the listed purchase price, minus the down payment. Write a program that takes the purchase price as input. The program should display a table, with appropriate headers, of a payment schedule for the lifetime of the loan. Each row of the table should contain the following items: The month number (beginning with 1) The current total balance owed The interest owed for that month The amount of principal owed for that month The payment for that month The balance remaining after payment The amount of interest for a month is equal to balance × rate / 12. The amount of principal for a month is equal to the monthly payment minus the interest owed.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY