1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zhuklara [117]
2 years ago
11

Write a C++ nested for loop code to print out the following onthe screen1 2 3 4 5 67 8 91 2 3 4 5 67 81 2 3 4 5 671 2 3 4 561 2

3 451 2 341 23121
Computers and Technology
1 answer:
Mekhanik [1.2K]2 years ago
6 0

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   

  //nested for loop

   for(int i=9;i>=1;i--){

       for(int j=1;j<=i;j++){

          cout<<j<<" ";  //display

       }

   }

   return 0;

}

Explanation:

Include the library iostream for using the input/output instruction in the c++ programming.

Create the main function and takes nested for loop. Nested for loop means, for loop inside the another for loop.

For every value of outside for loop, inside for loop execute.

we make outer for loop in decreasing format, means it start from 9 and goes to 1 and inside for loop make in increasing format, means loop start from 1 and it goes to that value which is provided by the outer loop.

and print the output for every cycle.

Lets dry run the code:

the outer loop starts from 9 and it checks the condition 9>=1, condition true. then the program moves to the inner loop which starts from 1 and goes to the 9.

first, it also checks the condition 1 <= 9, condition true and prints the number from 1 to 9.

then,  i is reduced by 1. it means i become 8.

then, the above process continues from 1 to 8 and so on...

the loop process will terminate if the outer loop terminate.

Finally, we get the output.

You might be interested in
Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the
Anna11 [10]

Answer:

The program in Python is as follows:

num1 = int(input())

num2 = int(input())

if num2 < num1:

   print("Second integer can't be less than the first.")

else:

   for i in range(num1,num2+1,5):

       print(i,end=" ")

Explanation:

This gets the first integer from the user

num1 = int(input())

This gets the second integer from the user

num2 = int(input())

If the second is less than the first, the following prompt is printed

<em>if num2 < num1:</em>

<em>    print("Second integer can't be less than the first.")</em>

If otherwise, the number between the intervals is printed with an increment of 5

<em>else:</em>

<em>    for i in range(num1,num2+1,5):</em>

<em>        print(i,end=" ")</em>

<em />

6 0
2 years ago
Decimal numbers are based on __________.
Shtirlitz [24]
Decimals are based on the preceding powers of 10. Thus, as we move from left to right, the place value of digits gets divided by 10, meaning the decimal place value determines the tenths, hundredths and thousandths. A tenth means one tenth or 1/10. In decimal form, it is 0.1.
6 0
3 years ago
Which of the following statements about security in the network is true?
Ilya [14]
I believe that answer A is true
5 0
2 years ago
Assume the user types in 7 and 10. What is output by the following?
Marianna [84]

Answer:

Enter a number: 7

Enter a number: 10

Traceback (most recent call last):

 File "main.py", line 3, in <module>

   print (numi + num2)

NameError: name 'numi' is not defined

Explanation:

The typo in the print statement causes a run-time error, where obviously num1+num2 was expected, and an output of 17.

3 0
3 years ago
HELP 15 POINTS
masya89 [10]

Answer:

A I think I might be wrong

6 0
3 years ago
Read 2 more answers
Other questions:
  • A disk rotates at a rate of 7200 revolutions per minute. Seek operations (i.e., moving the access head to a desired track) take
    6·1 answer
  • If a gas gosts 3.60 per gallon how much doe sit cost to drive 500 miles in the city
    5·1 answer
  • Complete the following:_____
    9·1 answer
  • If you've been a victim of identity theft, what should you do after contacting the company that reported the suspicious charge a
    9·1 answer
  • Microsoft ________ is a cloud storage and file sharing service
    12·1 answer
  • Select the correct answer.
    6·1 answer
  • Solve the following quadratic equation <br><br>y=6x^2-12x+1
    9·1 answer
  • Can anyone fill in the space please
    6·1 answer
  • Role of memory in a computer system
    10·1 answer
  • What is the different sheets in excel
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!