Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
code in c++
Write 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:).
Homework 5
CMP 167: Programming Methods I Lehman College, City University of New York
Homework 5-1
I
Write a program with a loop that iterates as long as an int variable called num is less or equal to 50.
Num must be initialized with a value of 1 and incremented by 1 with each iteration.
Each iteration of the loop must print all appropriate sentences for that number according to the following
1. If num is odd,
output: num is an odd number
2. If num is even,
output: num is an even number output: num is divisible by 2
3. If num is divisible by 2,
4. If num is divisible by 5,
output: num is divisible by 5
5. If num is divisible by 8,
output: num is divisible by 8
6. If num is divisible by 11,
output: num is divisible by 11
Please note that your class should be named FirstLoop.
Chapter 3 Solutions
Problem Solving with C++ (10th 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...Ch. 3 - You have an augmented reality game in which you...
Knowledge Booster
Similar questions
- Convert the following for loop to a while loop: for (int x = 50; x > 0; x--){ cout << x << " seconds to go.\n"; }arrow_forwardcode language in c++ using for loops and nested for loopsarrow_forwardWrite the following for loop as a while loop. for (int count = 1; count <= 10; count++) cout << count << endl ;arrow_forward
- in C++ Review - for loops, if-else, switch, functions Many computer applications, such as Microsoft Excel, can compare date values that occur after January 1, 1900. For example, these programs can determine if 06/06/99 is less than (comes before) 11/01/00. They use January 1, 1900 as their reference point. This becomes day 1. All other dates are calculated as to the number of days they are relative to January 1, 1900. For example January 2, 1900 is equal to 2. October 31, 2000 is equal to 36829. Notwithstanding, Excel cannot tell you which day of the week these two dates fell on. For this assignment, you are to write a C++ program which will: Have the User enter in a date. Calculate the "day value" of that date. For this you will need to write several functions as stated below. A function that determines if a year is a leap year. A function that determines the number of days in a month. Remember if the year is a leap year then February has 29 days. You…arrow_forwardWhat 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_forward
- C++ Coding: Nested Loops Create a constant DIM. Set DIM to 7, and use a nested loop to display the following square matrix output. Output Example: - - - X - - -- - - X - - -- - - X - - -X X X O X X X- - - X - - -- - - X - - -- - - X - - -arrow_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_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
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