Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5.8, Problem 5.17CP
Write a for loop that sums up the squares of the odd integers from 1 through 9.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C code, Write a for loop that prints in ascending order all the positive integers less than 200 that are divisible by both 2 and 3, separated by spaces.
a and b are int variables containing values and a > b.Write a for loop that computes the sum of numbers from a to b (both inclusive) numbers with the last 2-digits 50.(Example: if a=700, b=128, then it will compute 650+550+450+....+150)Write only initialization of sum, and the for loop with its block, nothing else.
display a rectangle of a given width and height, such as
****
Write a single for loop that displays the same rectangle.
Chapter 5 Solutions
Starting Out with C++: Early Objects (9th 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 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 - 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 - 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 - 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
Write a loop equivalent to the for loop above without using .
C Programming Language
List in chronological order the major events that take place when a process is interrupted.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What does the following code display? mystr = 'yes' mystr += 'no' mystr += 'yes' print (mystr)
Starting Out with Python (4th Edition)
If a class is named Student, what name can you use for a constructor for this class?
Java: An Introduction to Problem Solving and Programming (7th Edition)
Combine the statements that you wrote in Exercise 4.5 into a Java application that calculates and prints the su...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
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
- 2. Use any loop of your choice to print all numbers between 10 and 100 that are divisible by 5. Print the sum of all the numbers divisible by 5.arrow_forwardcode language in c++ using for loops and nested for loopsarrow_forwardPlease unroll the following loop three times. What is the benefit of loop unrolling? for (i=0; i<42; i++) { a[i] = b[i] * i;}arrow_forward
- Write a program that uses a for loop to display a table that lists in one column values for ounces, followed by columns that show the equivalent in pints, quarts and litres: Enter a start value, an end value and a step value for a range of values for the ounces. • Use a for loop to do the following for the range values: • Show on each line of the table four columns starting with the ounces, followed by the pints, quarts and litres. The formulas for the units are: • pints: ounces * 0.0625 • quarts: ounces * 0.03125 • litres: ounces * 0.02957 • Show all values in the table with two decimal places each, and right-aligned so all the decimal places are lined up with one another. Use a while loop to show the table. • Show the table from a high value to a low value.arrow_forwardPyhton Coding- Whille Loops How do I get this while loop to continue to run? It quits after one try. Thanks. Here is my coding so far. num=int(input('Enter a three-digit number only (type "1" to quit): '))#check if number of digits in number is 3 or notoddList=[]evenList=[]while num !=1:if len(str(num))==3:#check if number is evenif num%2==0:print("Your number,%s, is even"%(num))evenList.append(int(num))#if number is not even then print oddelse:print("Your number,%s, is odd"%(num))oddList.append(int(num))#first number odd or even#make number a listlistNum=list(str(num))firstNum=listNum[0]#if and else statements for odd or evenif int(firstNum)%2==0:print("%s is even."%(firstNum))evenList.append(int(firstNum))else:print("%s is odd"%(firstNum))oddList.append(int(firstNum))secondNum=listNum[1]if int(secondNum)%2==0:print("%s is even"%(secondNum))evenList.append(int(secondNum))else:print("%s is odd"%(secondNum))oddList.append(int(secondNum))thirdNum=listNum[2]if int(thirdNum)%2==0:print("%s…arrow_forwardWhat the following code does? Replace the while loop with a for loop in the code: int s=0, i=2; while(i<=200) { s=s+i; i=i+2; }arrow_forward
- i need the answer quicklyarrow_forwardWrite code that uses any type of loop. The code should continually ask for a user input and sums all user inputs that are divisible by 2. The loop should continue until the user enters a negative number. The code should output the sum a single time once user entry has completed. You may assume all libraries and namespaces have been previously written into the code, you are just writing everything that would go inside the main function (beyond the return 0:).arrow_forwardn1 and n2 contain integers, and n1 < n2.Write a Python program using for loop that prints all integer numbers from n1 to n2 both inclusive.arrow_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,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming Tutorial 36 - Intro to Loops; Author: Caleb Curry;https://www.youtube.com/watch?v=M3o7Y0juEP0;License: Standard YouTube License, CC-BY