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 5, Problem 40RQE
int x = 1 ;
while (x < 10)
x++;
cout << x;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
int func(int a, int b)
{
return (a
Q1
function myFunc() {
let a = 10;
if (true) {
Q3
}
}
let a = 5;
console.log(a);
Q4
console.log(a);
Q2
const square = num => num * num;
console.log(square(3) + 5);
myFunc();
let x = 30;
let y
"200";
console.log(x+y);
const nums = [10, 20, 8, 17];
nums.filter(e=> e > 10);
console.log(nums);
Q5
const nums = [30, 35, 42, 20, 15];
console.log(nums.every (num
=> num > 20));
January 15
What does the function f do?
struct Point2D
{
double x;
double y;
struct Triangle
{
Point2D v1;
Point2D v2;
Point2D v3;
};
void f(Triangle&t)
{
}
int temp = 12.5;
temp = t.v1.x;
t.v1.x = t.v1.y;
t.v1.y = temp;
}
int main ()
{
Triangle mytri;
mytri.v1.x = 1.0;
mytri.v1.y = 22.5;
f (mytri);
Swaps values of x and y in vertex 1 of an argument of type Triangle
Initializes value of x in vertex 1 of an argument of type Triangle
Sets all x,y values in all vertices of an argument of type Triangle
Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of type
Chapter 5 Solutions
Starting Out With C++: Early Objects (10th Edition)
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.6 - In the following program segment, which variable...Ch. 5.6 - Find four errors in the following code that is...Ch. 5.6 - Write a sentinel-controlled while loop that...Ch. 5.7 - Prob. 5.7CPCh. 5.7 - Write a program segment with a do-while loop that...Ch. 5.7 - Revise your answer to Question 5.8 to use the...Ch. 5.8 - What three expressions appear inside the...
Ch. 5.8 - You want to write a for loop that displays I love...Ch. 5.8 - Prob. 5.12CPCh. 5.8 - Write a for loop that displays your name 10 times.Ch. 5.8 - Write a for loop that displays all of the odd...Ch. 5.8 - Write a for loop that displays every fifth number,...Ch. 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.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.24CPCh. 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.28CPCh. 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 - If dataFi1e is an of stream object associated with...Ch. 5.12 - If dataFile is an ifstream object associated with...Ch. 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 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 - 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 - Complete the program segment below to write the...Ch. 5 - Complete the following program segment that reads...Ch. 5 - What will each of the following program segments...Ch. 5 - int x = 1 ; while (x 10) x++; cout x;Ch. 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 - Speed Conversion Chart Write a program that...Ch. 5 - Ocean Levels Assuming the level of the Earths...Ch. 5 - Circle Areas The formula to compute the area of a...Ch. 5 - Pennies for Pay Write a program that calculates...Ch. 5 - Weight Loss If moderately active persons cut their...Ch. 5 - Calories Burned Running on a particular treadmill,...Ch. 5 - Membership Fees Increase A country club, which...Ch. 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 - Student Line-Up A teacher has asked all her...Ch. 5 - Rate of Inflation The annual rate of inflation is...Ch. 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
Define an enumeration for each of the months in the year. Use a for-each statement to display each month.
Java: An Introduction to Problem Solving and Programming (8th Edition)
Write a program that takes an integer keyed in from the terminal and extracts and displays each digit of the in...
Programming in C
Feet to Inches One foot equals 12 inches. Design a function named feetToInches that accepts a number of feet as...
Starting Out with Programming Logic and Design (4th Edition)
Give an example of a data constraint.
Database Concepts (7th Edition)
What is a keyword? List some Java keywords.
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Draw a picture of the form shown in Figure 2.3, representing the initial state of a Student object following it...
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
- نقطة واحدة Let A = {a; b; c; d} and R= {(a; a); (b; c); (c; b); (d; d)} then R is Transitive Equivalent not transitivearrow_forwardNumber of digits int main() {int c=0;int i=3856; int l=i; while(l>0) {l=l/10; c++; } printf("%d",c); return 0; } Summation of digits int main() {int sum=0; int i=384; int l=i; while(l>0) { sum+=l%10; l=l/10;} printf("%d",sum); return 0; }arrow_forwardsum = 0; for (int i = 1; i< n; i = sum++ || 2*i)arrow_forward
- 3: The code on the right is supposed to be the ARM code for procA; however, there are problems with the ARM code. C code: int procA(int x, int y) { int perimeter = (x + y) * 2; I return perimeter; } ARM code: I procA: add rø, r1, r2 mov r1, rø lsl #1 bx lr push {lr} Give the corrected version of the ARM code for procA:arrow_forwardint calculatepower (int x, int y){ if (y > 0) return x* else return 1; int main (){ int num, pwr; cout > num; cout > pwr; cout <« "Number "<arrow_forwardFor the C++ program show on the next page, answer the questions that follow. The names g, j, x, and y are declared multiple times. Distinguish uses of these names using line numbers where they were declared as subscripts. a. At point A in the program, what names are in scope? b. At point A in the program, what variables are live? c. At point B in the program, what names are in scope? d. At point B in the program, what variables are live?arrow_forwardC++ Programming Problem: Newton is a brilliant mathematician and solving triangles problems fascinates him. Today he is given a sequence of positive integers V1, V2, ., VN. You must choose three elements Vx, Vy, Vz (x, y, z is vertices) such that the triangle formed have these properties: |XY|= Vz, |XZ|=Vy, |YZ|=Vx and the angle |ZYXZ|= 0 satisfies cose2P/Q, where 0 should be maximum possible. Find any such triangle or determine that it does not exist. Develop a C++ code which prints the value of x, y, z in a single line and print "Invalid" if not possible. Test Case: 412 9765 Result: 324arrow_forwardint main(){ long long int total; long long int init; scanf("%lld %lld", &total, &init); getchar(); long long int max = init; long long int min = init; int i; for (i = 0; i < total; i++) { char op1 = '0'; char op2 = '0'; long long int num1 = 0; long long int num2 = 0; scanf("%c %lld %c %lld", &op1, &num1, &op2, &num2); getchar(); long long int maxr = max; long long int minr = min; if (op1 == '+') { long long int sum = max + num1; maxr = sum; minr = sum; long long int res = min + num1; if (res > maxr) { max = res; } if (res < minr) { minr = res; } } else { long long int sum = max * num1; maxr = sum; minr = sum; long long int res = min * num1;…arrow_forwardC++ Programming, Arrays Lights The park is illuminated by n (1 < n < 100) lights. Each of them shines all night or not. Of course, which lights were on the first night and which were not. Every other night the condition of the lamps shall be determined by the following rules: the lamp will not illuminate if both of its neighbors were lit last night; the lamp shall illuminate if one of its neighbors was illuminated last night and the other was not; if neither of the first two rules applies to the lamp, it will illuminate when the night is even and will not illuminate when the night is odd. Create a program to determine which lights are on and which will not be lit when k (1 < k < 100) nights have elapsed, and to find which night the most lights were lit and which the least. If there are several identical nights with the most or least lights lit, the night with the lower number must be indicated. The first line of the original data file contains two integers: the number of…arrow_forwardAnswer in JavaScript Tim while preparing for his CAT exam, was studying the topic Number Systems. He encountered a loving da question: Given a number N, find the number of pairs (cy) where both x and y are less than N and Highent Common Factor(HCF) of x and y is 1. You have to solve the question for him. Note: 0 can be included within the pairs Input Specification: Input: The number N from which the pairs (x,y) should be obtained Output Specification: Return the total number of pairs Example 1: input1: 4 Output: 9 Explanation: The pairs can be (1,0) ,(0,1) (1,1) (1,2) (2,1) (0, 3) (3,1) (2,3) (0,2) So, a total of 9 pairsarrow_forwardint main(int argc, char **argv) { float *rainfall; float rain_today; // rainfall has been dynamically allocated space for a floating point number. // Both rainfall and rain today have been initialized in hidden code. // Assign the amount in rain_today to the space rainfall points to. return 0; }arrow_forwardfunction myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x)) when invoked on x.}arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author: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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges; Author: FreecodeCamp.org;https://www.youtube.com/watch?v=oBt53YbR9Kk;License: Standard YouTube License, CC-BY