Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3.6, Problem 3.21CP
What will the following
int unus, duo, tres;
unus =duo= t res = 5 ;
unus += 4;
duo *= 2 ;
tres −= 4;
unus /= 3;
duo += tres;
cout << unus << endl <<duo<< endl << tres << endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function.
The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options.
You will need to add an if statement in the choice() function to make the correct selection.
#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 %…
#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 %…
Chapter 3 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 3.1 - Prob. 3.1CPCh. 3.1 - What is the symbol called?Ch. 3.1 - Where does cin read its input from?Ch. 3.1 - Prob. 3.4CPCh. 3.1 - Assume value is an integer variable. If the user...Ch. 3.1 - A program has the following variable definitions....Ch. 3.1 - The following program will run, but the user will...Ch. 3.1 - Complete the following main function so that it...Ch. 3.2 - In each of the following cases, tell which...Ch. 3.2 - Complete the following table by writing the value...
Ch. 3.2 - Prob. 3.11CPCh. 3.2 - Study the following program code and then complete...Ch. 3.2 - Complete the following program skeleton so that it...Ch. 3.3 - Assume the following variable definitions: int a =...Ch. 3.3 - What will the following program code display if a...Ch. 3.3 - What will the following program code display? int...Ch. 3.5 - Prob. 3.17CPCh. 3.5 - Complete the following program code segment so...Ch. 3.6 - Write a multiple assignment statement that assigns...Ch. 3.6 - Write statements using combined assignment...Ch. 3.6 - What will the following program segment display?...Ch. 3.7 - Write cout statements with stream manipulators...Ch. 3.7 - The following program segment converts an angle in...Ch. 3.8 - Will the following string literal fit in the space...Ch. 3.8 - If a program contains the definition string name;...Ch. 3.8 - Prob. 3.26CPCh. 3.10 - Use a mathematical library function with a cout...Ch. 3.10 - Assume the variables angle1 and angle2 hold angles...Ch. 3.10 - To find the cube root (the third root) of a...Ch. 3.10 - Write a statement that produces a random number...Ch. 3 - Prob. 1RQECh. 3 - Prob. 2RQECh. 3 - Prob. 3RQECh. 3 - Assume the following variables are defined: int...Ch. 3 - What header files must be included in the...Ch. 3 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...Ch. 3 - Is the following code legal? Why or why not? const...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - What header file must be included A) to perform...Ch. 3 - Pet World offers a 15 percent discount to senior...Ch. 3 - A bowling alley is offering a prize to the bowler...Ch. 3 - A retail store grants its customers a maximum...Ch. 3 - Little Italy Pizza charges 14.95 for a 12-inch...Ch. 3 - A) (Assume the user enters George Washington.)...Ch. 3 - Each of the following program segments has some...Ch. 3 - A) const int number1, number2, product; cout ...Ch. 3 - Soft Skills Often programmers work in teams with...Ch. 3 - Miles per Gallon Write a program that calculates a...Ch. 3 - Stadium Seating There are three searing categories...Ch. 3 - How Much Insurance? Many financial experts advise...Ch. 3 - Test Average Write a program that asks for five...Ch. 3 - Average Rainfall Write a program that calculates...Ch. 3 - Male and Female Percentages Write a program that...Ch. 3 - Vacation Days Write a program that prompts the...Ch. 3 - How Many Widgets? The Yukon Widget Company...Ch. 3 - How many Calories? A bag of cookies holds 30...Ch. 3 - Ingredients Adjuster A cookie recipe calls for the...Ch. 3 - Celsius to Fahrenheit Write a program that...Ch. 3 - Monthly Sales Tax A retail company muse file a...Ch. 3 - Property Tax Madison County collects property...Ch. 3 - Senior Citizen Property Tax Madison County...Ch. 3 - Math Tutor Write a program that can be used as a...Ch. 3 - Interest Earned Assuming there are no deposits...Ch. 3 - Monthly Payments The monthly payment on a loan may...Ch. 3 - Pizza Slices Joe's Pizza Palace needs a program to...Ch. 3 - How Many Pizzas? Modify the program you wrote in...Ch. 3 - Angle Calculator Write a program that asks the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Male and Female Percentages Write a program that asks the user for the number of males and the number of female...
Starting Out with Python (3rd Edition)
Write a program that uses the class SalariedEmployee in Display 15.5. Your program is to define a class called ...
Problem Solving with C++ (9th Edition)
What is denormalization?
Database Concepts (8th Edition)
Car Loan If A dollars are borrowed at r interest compounded monthly to purchase a car with monthly payments for...
Introduction To Programming Using Visual Basic (11th Edition)
File Head Display Write a program that asks the user for the name of a file. The program should display only th...
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
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 (9th Edition) (What's New in Computer Science)
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_forwardDice_Game.cpp #include <iostream>#include "Die.h" using namespace std; // a struct for game variablesstruct GameState { int turn = 1; int score = 0; int score_this_turn = 0; bool turn_over = false; bool game_over = false; Die die;}; // declare functionsvoid display_rules();void play_game(GameState&);void take_turn(GameState&);void roll_die(GameState&);void hold_turn(GameState&); int main() { display_rules(); GameState game; play_game(game);} // define functionsvoid display_rules() { cout << "Dice Game Rules:\n" << "\n" << "* See how many turns it takes you to get to 20.\n" << "* Turn ends when you hold or roll a 1.\n" << "* If you roll a 1, you lose all points for the turn.\n" << "* If you hold, you save all points for the turn.\n\n";} void play_game(GameState& game) { while (!game.game_over) { take_turn(game); } cout << "Game…arrow_forwardDice_Game.cpp #include <iostream>#include "Die.h" using namespace std; // a struct for game variablesstruct GameState { int turn = 1; int score = 0; int score_this_turn = 0; bool turn_over = false; bool game_over = false; Die die;}; // declare functionsvoid display_rules();void play_game(GameState&);void take_turn(GameState&);void roll_die(GameState&);void hold_turn(GameState&); int main() { display_rules(); GameState game; play_game(game);} // define functionsvoid display_rules() { cout << "Dice Game Rules:\n" << "\n" << "* See how many turns it takes you to get to 20.\n" << "* Turn ends when you hold or roll a 1.\n" << "* If you roll a 1, you lose all points for the turn.\n" << "* If you hold, you save all points for the turn.\n\n";} void play_game(GameState& game) { while (!game.game_over) { take_turn(game); } cout << "Game…arrow_forward
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void 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);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forward#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void 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);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forward#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void 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);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forward
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void 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);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forwardDetermine 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;arrow_forwardC++ beginnerarrow_forward
- Coin Toss Write a function named coinToss that simulates the tossing of a coin. When you call the function, it should generate a random number in the range of 1 through 2. If the random number is 1, the function should display "heads". If the random number is 2, the function should display "tails". Demonstrate the function in a program that sks the user how many times the coin should be tossed and the coin then simulates the tossing of the coin that number of times.arrow_forward// P41.cpp - A simple elevator for 4 floors and a basement with a // close door button and 5 keys for floors #include<iostream> #include<cmath> using namespace std; void close_door(); int change_floor(int choice, int floor); int main( ) { int key; int floor = 0; cout << "Press a Key \n"; cin >> key; if(key == 0) { close_door(); if( floor != 0){ // otherwise nothing happens cout << "I am moving to the Basement \n"; floor = change_floor(0, floor); } } else if(key == 1) { close_door(); if( floor != 1){ // otherwise nothing happens cout << "I am moving to the the First Floor \n"; floor = change_floor(1, floor); } } else if(key == 2) { close_door(); if( floor != 2){ // otherwise nothing happens cout << "I am moving to the the Second Floor \n"; floor = change_floor(2, floor); } } else if(key == 3) { close_door(); if( floor != 3){ // otherwise nothing happens cout << "I am moving to the the Third Floor \n"; floor = change_floor(3, floor); } }…arrow_forwardQUESTION 21 int x1=200; int y1=3003; int z1, z2, z3, z4; int d1, d2, d3; _asm{ mov EAX, x1; 200 mov EBX, y1; 300 mov z1, ESP; assume initial ESP: OFFF FFEA add EAX, x1; 400 push EAX; mov d1, EAX:400 mov z2, ESP; push EBX; SUB EBX, x1; 300-200=100 mov d2, EBX; mov 23, ESP; POP ECX; MOV d3, ECX; MOV z4, ESP; POP EDX; mov d4, EDX; What is z3 in Hexidecimal? O OFFF FFEA O OFFF FFE6 OFFF FFE2 OFFF FFEEarrow_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
Introduction to Variables; Author: Neso Academy;https://www.youtube.com/watch?v=fO4FwJOShdc;License: Standard YouTube License, CC-BY