Question

Construct a program that first prints out 15, then 14, then 12, then 9 and finally...

Construct a program that first prints out 15, then 14, then 12, then 9 and finally 5 on consecutive lines.

arranging these given lines:

  • MAX = 5
  • print(sum)
  • j = j - 1
  • while i < MAX:
  • i = i + 1
  • j = MAX
  • i = 0
  • while j > i:
  • sum = 0
  • sum = sum + j

Homework Answers

Answer #1

Short Summary:

Provided the source code and sample output as per the requirements.

Source Code:

MAX = 5
i = 0
while i < MAX:
sum = 0
j = MAX
while j > i:
sum = sum + j
j = j - 1
print(sum)
i = i + 1

Refer the following screenshots for code indentation:

Sample Run:

**************************************************************************************

Feel free to rate the answer and comment your questions, if you have any.

Please upvote the answer and appreciate our time.

Happy Studying!!!

**************************************************************************************

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their...
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their sum, (3) prints out the first divided by the second, and (4) prints out the natural log of the first number raised to the power of the second number. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes here> return 0; }
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
5) Write a java program with scanner object to input first number and second number as...
5) Write a java program with scanner object to input first number and second number as variable with input statement and system out print statement. Steps: 1) Declare scanner object 2) Ask system out print for first number and declare variable first number 3) Ask system out print for second number and declare variable second number 4) Declare first for loop where variable int i has already a value (your choice), that i is less then equal to ? and...
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
9. Construct a triangle given: side a, altitude a (h_a), and median a (m_a) provide the...
9. Construct a triangle given: side a, altitude a (h_a), and median a (m_a) provide the steps used to construct it. 12. Given three (infinite) straight lines. Construct a circle that touches the first two lines nad has its center on the third line. 14. Construct a circle, being given one point on it, one straight line tangent to it, and its radius.
9. Construct a triangle given: side a, altitude a (h_a), and median a (m_a) provide the...
9. Construct a triangle given: side a, altitude a (h_a), and median a (m_a) provide the steps used to construct it. 12. Given three (infinite) straight lines. Construct a circle that touches the first two lines nad has its center on the third line. 14. Construct a circle, being given one point on it, one straight line tangent to it, and its radius.
Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program...
Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program to construct array ODD[] and EVEN[] from Arr[10] as you realize ODD[] consists of odd number and EVEN[] consists of even number. for c++
C++ PROGRAM. (C++ INTRO QUESTION) Write a program that prints the count of all prime numbers...
C++ PROGRAM. (C++ INTRO QUESTION) Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 55000 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules:...
Write a program that does the following and prints out the result          Use a do-while...
Write a program that does the following and prints out the result          Use a do-while loop and switch statement          Enter value x and a case number n          for n = 0 exit else continue          n=100 result = x * 9          n=102 result = x + 10 and continue          n=103 result = (x + 10) * x          n=104 and 106 result = x / x default    result = 99; test with x =...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT