Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3.4, Problem 38STE
Explanation of Solution
Program:
//Include necessary header files
#include <iostream>
//Declare namespace
using namespace std;
//Define the main function
int main()
{
//Variable declaration
int n, m;
//Outer for loop to iterate n value
for(n=1;n<=10;n++)
//Inner or nested for loop to iterate m value
for(m=1;m>=1;m--)
//Print the result
cout<<nn&#...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
i=10; for (int x=5; x
code in c++
Please unroll the following loop three times. What is the benefit of loop unrolling?
for (i=0; i<42; i++) { a[i] = b[i] * i;}
Chapter 3 Solutions
Problem Solving with C++ (9th Edition)
Ch. 3.1 - Determine the value, true or false, of each of the...Ch. 3.1 - Name two kinds of statements in C++ that alter the...Ch. 3.1 - In college algebra we see numeric intervals given...Ch. 3.1 - Prob. 4STECh. 3.2 - What output will be produced by the following...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 9...
Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - Write a multiway if-else statement that classifies...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - Prob. 19STECh. 3.2 - Though we urge you not to program using this...Ch. 3.3 - Prob. 21STECh. 3.3 - Prob. 22STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 25STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 27STECh. 3.3 - For each of the following situations, tell which...Ch. 3.3 - Rewrite the following loops as for loops. a.int i...Ch. 3.3 - What is the output of this loop? Identify the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What does a break statement do? Where is it legal...Ch. 3.4 - Write a loop that will write the word Hello to the...Ch. 3.4 - Write a loop that will read in a list of even...Ch. 3.4 - Prob. 38STECh. 3.4 - Prob. 39STECh. 3.4 - What is an off-by-one loop error?Ch. 3.4 - You have a fence that is to be 100 meters long....Ch. 3 - Write a program to score the paper-rock-scissor...Ch. 3 - Write a program to compute the interest due, total...Ch. 3 - Write an astrology program. The user types in a...Ch. 3 - Horoscope Signs of the same Element are most...Ch. 3 - Write a program that finds and prints all of the...Ch. 3 - Buoyancy is the ability of an object to float....Ch. 3 - Write a program that finds the temperature that is...Ch. 3 - Write a program that computes the cost of a...Ch. 3 - (This Project requires that you know some basic...Ch. 3 - Write a program that accepts a year written as a...Ch. 3 - Write a program that scores a blackjack hand. In...Ch. 3 - Interest on a loan is paid on a declining balance,...Ch. 3 - The Fibonacci numbers F are defined as follows. F...Ch. 3 - The value ex can be approximated by the sum 1 + x...Ch. 3 - Prob. 8PPCh. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 13 from Chapter 2 but...Ch. 3 - The keypad on your oven is used to enter the...Ch. 3 - The game of 23 is a two-player game that begins...Ch. 3 - Holy digits Batman! The Riddler is planning his...
Knowledge Booster
Similar questions
- Java coding platformarrow_forwardThe following do...while loop rewritten as a for loop would be: int num = 5; do { System.out.print(num + " " ); num *= 3; //num = num * 3; } while (num <= 30); All of these are correct. int num = 5; for (num <= 30) { System.out.print(num + " "); num *= 3; } for (int num = 5; num <= 30) { System.out.print(num + " "); num *= 3; } for (int num = 5; num <= 30; num *= 3) { System.out.print(num + " " ); }arrow_forwardcode language in c++ using for loops and nested for loopsarrow_forward
- Write the following for loop as a while loop. for (int count = 1; count <= 10; count++) cout << count << endl ;arrow_forwardRewrite the following using a while-loop instead of a for-loop: int main(){ intk; int sum=0; for(k=10;k<50;k+=){ sum=sum+k; } cout<<"sum= " <<sum<<endl; system("pause"); return0;arrow_forwardLoops: Based on the following code segment: int val = 10; String s = String.format("%d", val - 5); while (val < 25) { s +=String.format(",%3d", val); val += 5; } System.out.println(s); Select the code using a for loop that produces identical output: String s = String.format("%d", val); for (int val = 10; val < 25; val + 5) { s += String.format(",%3d", val); } System.out.println(s); Strings = String.format("%d", 5); for (int val = 10; val <= 25; val += 5) { s +=String.format(",%3d", val); } System.out.println(s); String s = String.format("%d", 5); for (int val s += String.format(",%3d", val); } == 10; val < 25; val + 5) { System.out.println(s); None of these will produce the same output. String s = String.format("%d", 5); for (int val = 10, val < 25, val += 5) { s += String.format(",%3d", val); } System.out.println(s); Strings = String.format("%d", 5); for (int val = 10; val < 25; val += 5) { s +=String.format(",%3d", val); } System.out.println(s); String s = String.format("%d", 5); for…arrow_forward
- What is the number of times the following loop is executed? for the value of b in (1,10): a printout of barrow_forwardthe total number of iterations of nested loops can be calculated by : O a. outer loop iterations / inner loop iterations O b. outer loop iterations + inner loop iterations O c. outer loop iterations - inner loop iterations O d. outer loop iterations * inner loop iterationsarrow_forwarda 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.arrow_forward
- What 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_forwardA semicolon (;) is necessary at the end of which type of the loop? All loops do-while while forarrow_forwardFactorials The factorial of n (written n!) is the product of the integers between 1 and n. Thus 4! = 1*2*3*4 = 24. By definition, 0! = 1. Factorial is not defined for negative numbers. Write a program that asks the user for a non-negative integer and computes and prints the factorial of that integer. You'll need a while loop to do most of the work-this is a lot like computing a sum, but it's a product instead. And you'll need to think about what should happen if the user enters 0. 1. 2. Now modify your program so that it checks to see if the user entered a negative number. If so, the program should print a message saying that a nonnegative number is required and ask the user the enter another number. The program should keep doing this until the user enters a nonnegative number, after which it should compute the factorial of that number. Hint: you will need another while loop before the loop that computes the factorial. You should not need to change any of the code that computes the…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,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr