Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5, Problem 66RQE
// This
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
char again;
while (again == 'y’ || again == 'Y')
cout ≪ "Enter a number: ";
cin ≫ num1;
cout ≪ "Enter another number: ";
cin ≫ num2;
cout ≪ "Their sum is ≪ (num1 + num2) ≪ endl
cout ≪ "Do you want to do this again? ";
cin ≫ again;
return 0;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include
#include
#include
#include
using namespace std;
int main (){
const double PI = 3.14159265359;
return 0;
}
int x1 = 66;
int y1 = 39;
int d;
_asm {
}
mov EAX, X1;
mov EBX, y1;
push EAX;
push EBX;
pop ECX
mov d, ECX;
What is d in decimal format?
None
[] # Don't write code in this line
Q5: Complete the function that calculates the position of an object at any time t> 0. The initial position and the initial velocity (at time t=0) are denoted as so and v0 respectively. The object undergoes constant acceleration a, for any time t>0.
[ ]: def calculate_position (s0,u,a,t):
"given the initial conditions and acceleration, return the object's position.
Use the variable named 'position' to hold and return this value """
# YOUR CODE HERE
return position
I
↑↓古早
Check your code here "
Assign random input variables and check the answer"
Chapter 5 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 5.1 - What will the following program segments display?...Ch. 5.3 - Write an input validation loop that asks the user...Ch. 5.3 - Write an input validation loop that asks the user...Ch. 5.3 - Write an input validation loop that asks the user...Ch. 5.5 - Prob. 5.5CPCh. 5.6 - Name the three expressions that appear inside the...Ch. 5.6 - You want to write a for loop that displays I love...Ch. 5.6 - Prob. 5.8CPCh. 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 - Write a for loop that repeats seven times, asking...Ch. 5.8 - In the following program segment, which variable...Ch. 5.8 - Prob. 5.14CPCh. 5.8 - How would you modify Program 5-13 so any negative...Ch. 5.11 - What is an output file? What is an input file?Ch. 5.11 - What three steps must be taken when a file is used...Ch. 5.11 - What is the difference between a text file and a...Ch. 5.11 - Budget Analysis Write a program that asks the user...Ch. 5.11 - Random Number Guessing Game Write a program that...Ch. 5.11 - What type of file stream object do you create if...Ch. 5.11 - Write a short program that uses a for loop to...Ch. 5.11 - Write a short program that opens the file created...Ch. 5 - Why should you indent the statements in the body...Ch. 5 - Describe the difference between pretest loops and...Ch. 5 - Why are the statements in the body of a loop...Ch. 5 - What is the difference between the while loop and...Ch. 5 - Which loop should you use in situations where you...Ch. 5 - Which loop should you use in situations where you...Ch. 5 - Which loop should you use when you know the number...Ch. 5 - Why is it critical that counter variables be...Ch. 5 - Why is it critical that accumulator variables be...Ch. 5 - Why should you be careful not to place a statement...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 data type do you use when you want to create...Ch. 5 - Why should a program close a file when its...Ch. 5 - What is a files read position? Where is the read...Ch. 5 - To ______ a value means toincreaseit by one,and to...Ch. 5 - Prob. 17RQECh. 5 - Prob. 18RQECh. 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 variablethatcountsthe number of...Ch. 5 - A(n) _____ is a sum of numbers that accumulates...Ch. 5 - A(n) _____ is a variable that is initialized to...Ch. 5 - Prob. 27RQECh. 5 - The _____ loop always iterates at least once.Ch. 5 - The _____ and _____ loops will not iterate at all...Ch. 5 - The _____ loop is ideal for situations that...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...Ch. 5 - The _____ statement causes _____ a loop to skip...Ch. 5 - Write a while loop that lets the user enter a...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 10 rows of #...Ch. 5 - Convert the following while loop to a do-while...Ch. 5 - Convert the following do-while loop to a while...Ch. 5 - Convert the following while loop to a for loop:...Ch. 5 - Convert the following for loop to a while loop:...Ch. 5 - Write code that does the following: Opens an...Ch. 5 - Write code that does the following: Opens the...Ch. 5 - Modify the code that you wrote in Question 45 so...Ch. 5 - T F The operand of the increment and decrement...Ch. 5 - T F The cout statement in the following program...Ch. 5 - T F The cout statement in the following program...Ch. 5 - T F The while loop is a pretest loop.Ch. 5 - T F The do-while loop is a pretest loop.Ch. 5 - T F The for loop is a posttest loop.Ch. 5 - T F It is not necessary to initialize counter...Ch. 5 - T F All three of the for loops expressions may be...Ch. 5 - T F One limitation of the for loop is that only...Ch. 5 - T F Variables may be defined inside the body of a...Ch. 5 - T F A variable may be defined in the...Ch. 5 - T F In a nested loop, the outer loop executes...Ch. 5 - T F In a nested loop, the inner loop goes through...Ch. 5 - T F To calculate the total number of iterations of...Ch. 5 - T F The break statement causes a loop to stop the...Ch. 5 - T F The continue statement causes a terminated...Ch. 5 - T F In a nested loop, the break statement only...Ch. 5 - Prob. 64RQECh. 5 - // Find the error in this program. #include...Ch. 5 - // This program adds two numbers entered by the...Ch. 5 - // This program uses a loop to raise a number to a...Ch. 5 - // This program averages a set of numbers....Ch. 5 - // This program displays the sum of two numbers....Ch. 5 - // This program displays the sum of the numbers...Ch. 5 - Sum of Numbers Write a program that asks the user...Ch. 5 - Characters for the ASCII Codes Write a program...Ch. 5 - Ocean Levels Assuming the oceans level is...Ch. 5 - Calories Burned Running on a particular treadmill...Ch. 5 - Membership Fees Increase A country club, which...Ch. 5 - Distance Traveled The distance a vehicle travels...Ch. 5 - Pennies for Pay Write a program that calculates...Ch. 5 - Math Tutor This program started in Programming...Ch. 5 - Hotel Occupancy Write a program that calculates...Ch. 5 - Average Rainfall Write a program that uses nested...Ch. 5 - Population Write a program that will predict the...Ch. 5 - Celsius to Fahrenheit Table In Programming...Ch. 5 - The Greatest and Least of These Write a program...Ch. 5 - Student Line Up A teacher has asked all her...Ch. 5 - Payroll Report Write a program that displays a...Ch. 5 - Savings Account Balance Write a program that...Ch. 5 - Sales Bar Chart Write a program that asks the user...Ch. 5 - Prob. 18PCCh. 5 - Budget Analysis Write a program that asks the user...Ch. 5 - Random Number Guessing Game Write a program that...Ch. 5 - Random Number Guessing Game Enhancement Enhance...Ch. 5 - Square Display Write a program that asks the user...Ch. 5 - Pattern Displays Write a program that uses a loop...Ch. 5 - Using FilesNumeric Processing If you have...Ch. 5 - Prob. 25PCCh. 5 - Personal Web Page Generator Write a program that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Repeat Programming Project 11 from Chapter 10 but use an array to store the movie ratings instead of separate v...
Problem Solving with C++ (9th Edition)
This type of file contains data that has not been converted to text. a. text file b. binary file c. Unicode fil...
Starting Out with Python (4th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts of Programming Languages (11th Edition)
Run the hello, world program on your system. Experiment with leaving out parts of the program, to see what erro...
C Programming Language
Write a mutator method called setAge that takes a single parameter of type int and sets the value of a field ca...
Objects First with Java: A Practical Introduction Using BlueJ (6th 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
- Circle Properties Write a program that prompts for and accepts the diameter of a circle as a floating point number. The program should calculate and output the area and circumference of the circle. A sample run of the program should look like this: Enter circle diameter: 2.5 The area is 4.91 and the circumference is 7.85. Use 3.14159 as your constant for pi. global main ; exposes program entry point to the linkerextern printf ; declare external functionextern scanf section .text ; start of code segment main: push rbp ; preserve base pointer mov rbp,rsp ; copy stack pointer to base pointer pop rbp ; restore base pointer mov rax, 0 ; exit status (0 = success) ret section .data ; start of initialized data segment section .bss ; start of uninitialized data segment section .dataprompt db "Enter circle diameter: ", 0format db "The area is %0.2f and the circumference is %0.2f.", 0pi dq 3.14159…arrow_forwardpls debug this pseudocode // A high school is holding a recycling competition,// and this program allows a user to enter a student's // year in school (1 through 4) and number of cans collected// for recycling. Data is entered continuously until the user// enters 9 for the year.// After headings, output is four lines --// one for each school year class.start Declarations num year num cans num SIZE = 4 num QUIT = 9 num collectedArray[SIZE] = 0, 0, 0 string HEAD1 = "Can Recycling Report" string HEAD2 = "Year Cans Collected" output "Enter year of student or ", QUIT, " to quit " input year while year <> QUIT output "Enter number of cans collected " input cans collectedArray[year] = collectedArray[year] + cans output "Enter year of student or ", QUIT, " to quit " input year endwhile output HEAD1 output HEAD2 year = 1 while year < SIZE output year, collectedArray[year] year = year + 1…arrow_forward/* Program Name: BadDate.cpp Function: This program determines if a date entered by the user is valid. Input: Interactive Output: Valid date is printed or user is alerted that an invalid date was entered */ #include <iostream> bool validateDate(int, int, int); using namespace std; int main() { // Declare variables int year; int month; int day; const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31; bool validDate = true; // This is the work of the housekeeping() method // Get the year, then the month, then the day // This is the work of the detailLoop() method // Check to be sure date is valid if(year <= MIN_YEAR) // invalid year validDate = false; else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month validDate = false; else if (day < MIN_DAY || day > MAX_DAY) // invalid day validDate = false; // This is the work of the endOfJob()…arrow_forward
- 37. #include int main() { int num = 5; printf(" The value of num is %d ", num ); What is printed?arrow_forwardDate: Lab Objectives This lab was designed to reinforce the following programming concepts: Using repetition structures. Using decision making Using /0 files. Exercise#1: Counting Number of Digits Write a Java program that inputs one integer number from the user, determine the number af individual digits and prin the number of digits and the digits separated from one another by a tab space. For example, if the user types in the numbe 42339, the program should print "There are 5 digits, which are 4 2339", Sample Input/Output Enter an integer value: 12345678 There are(8 aigite, wrich are(1)2 3 45676 num/13 Exercise#2: Sales A mal-order house sells five products whose retail arices are as follows: Procuct 1. $2. sa; product 2, 54.50; product 3, 34. 481 Eroduct 4. $4.99 and product 5. $6.87. Write a Java program that reads a series of pairs as foliows: product number and product name. The quantity sold is generated at randam between O and 50. Your program should n a svitch statem.ent to…arrow_forward// LargeSmall.cpp - This program calculates the largest and smallest of three integer values. #include <iostream> using namespace std; int main() { // This is the work done in the housekeeping() function // Declare and initialize variables here int largest; // Largest of the three values int smallest; // Smallest of the three values // Prompt the user to enter 3 integer values // Write assignment, add conditional statements here as appropriate // This is the work done in the endOfJob() function // Output largest and smallest number. cout << "The largest value is " << largest << endl; cout << "The smallest value is " << smallest << endl; return 0; }arrow_forward
- The following declaration, program, and program segment has errors. Locate as many as you can. struct TwoVals { int a, b; };int main() { TwoVals.a = 10; TwoVals.b = 20; return 0;}arrow_forwardbe recor #include #include minutes #include limit on int func(int, int, int, int); main(){ srand(time(NULL)); int a, b, c, fNum; printf("Choose three different numbers between 0-39:"); scanf ("%d%d%d", &a, &b, &c); fNum = func (a, b, c, 25); printf("\nThe result: %d", fNum); } int func (int ul, int u2, int u3, int iter){ srand (time (NULL)); int n1=0, i=0, count=0; for (;iarrow_forwardplease correct this code i didnt get the mistake #include<stdio.h>#define NROWS 8#define NCOLS 8#define TRUE 1#define FALSE 0 void main(){ int queenht_row, queenht_col; int line,row,col,i,j; int filled; printf("Chess queenht Program\n"); do{ printf("Enter queenht's coordinates: "); scanf("%d %d",&queenht_row,&queenht_col); }while((queenht_row<1)||(queenht_row>NROWS)||(queenht_col<1)||(queenht_col>NCOLS)); for(line=1;line<=2*NROWS+1;line++){ row = line/2; if(line%2!=0){ printf("+"); for(col=1;col<=NCOLS;col++) printf("---+"); printf("\n"); } else{ printf("|"); for(col=1;col<=NCOLS;col++){ filled=FALSE; if((row==queenht_row) && (col==queenht_col)){ printf(" Q |"); filled = TRUE; continue; }…arrow_forwardTest Average and Grade - MUST BE WRITTEN IN PSEUDOCODEarrow_forward#include using namespace std; int main() int x=1,y=2; for (int i=0; i<3; i++) e{ x=x*y; 8{ } cout<arrow_forward'Q1 Write a {pmgram that reads 10 numbers and then finds the latgest number and prints it and finds the smallest number and prints it.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY