Write a program that prints the following 45 pairs of numbers:
11
21
22
31
32
33
41
42
43
44
51
***
97
98
99
Note that the first numbers go from 1 to 9, and the second numbers start at 1 and go up to the
value of the first number (9 times). You must use loops to do this not 45 print statements.

Respuesta :

Answer:

  • Code is in JAVA language. As there is no user input the logic is straightforward.
  • Below is the code along with a detailed explanation of the logic.
  • The class name is Print main save as file as the main class.

Explanation:

Program:-

public class Main{

public static void main(String args[]){

/* There are two for loops...

* First for loop runs from i=1 to i=9

* Second for loop runs from j=1 to j=i.

*

*/

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

for(int j=1;j<=i;j++){ // j loop runs from j=1 to j=i

/*Prints I and j next to each other*/

System.out.println(i+""+j);

}//for loop of j ends here

}// for loop of I ends here

}

}