While loop- printTable - Java | Practice | GeeksforGeeks

While loop is another loop like for loop but unlike for loop it only checks for one condition.
Here, we will use a while loop and print a number n's table in reverse order.
Example 1:
Input:
1

Output:
10 9 8 7 6 5 4 3 2 1

Example 2:
Input:
2

Output:
20 18 16 14 12 10 8 6 4 2
User Task: 
Your task is to complete the provided function and print the table in reverse order (with space between the values).
NOTE: As the code is checked against multiple test cases, the new line is necessary after every execution and the template code has taken care of that.
Constraints:
1 <= n<= 1000
0
arpandutta5033 weeks ago
Int I= 0;
While (i<11){
System .Out.println(I);
}
+1
shrutidhongade161 month ago
class Geeks {
	 static void printTable (int n) 
	 {
            int multiplier=10;
            while(multiplier>0)
            {
                System.out.print(n * multiplier + " ");
                multiplier -= 1;
                //Your code here
            }
       System.out.println();
	 }

}
0
janmejayy2 months ago
 static void printTable (int n)  {                      for(int i=10;i>0;i--){               System.out.print(n*i+" ");           }      System.out.println(); }
0
piyushchpkumar2 months ago
JAVA SOLUTION
 
  static void printTable (int n)  {           int multiplier=10;           while(multiplier>0)           {               //Your code here               System.out.print(multiplier*n+ " ");               multiplier--;           }      System.out.println(); }
0
mdsaif04052 months ago
class Geeks {
	 static void printTable (int n) 
	 {
            int multiplier=10;
            while(multiplier>0)
            {
                System.out.print(n*multiplier + " "); 
                multiplier--;
            }
            System.out.println();
	 }

}
0
mdsaif0405
This comment was deleted.
0
sdsapkale4 months ago
class Geeks { static void printTable (int n)  {           int multiplier=10;           while(multiplier>0)           {               //Your code here               System.out.print(multiplier*n+" ");               multiplier--;                          }      System.out.println(); }
}
0
badgujarsachin834 months ago
 static void printTable (int n) 
	 {
            int multiplier=10;
            while(multiplier>0)
            {
                //Your code here
                System.out.print(n*multiplier+" ");
            }
       System.out.println();
	 }
-1
rawalaashi017 months ago
class Geeks { static void printTable (int n)  {           int multiplier=10;           while(multiplier>0)           {               //Your code here                    System.out.print(n*multiplier +" ");       //return(n*multiplier);      multiplier--;       }System.out.println();
 }
}
0
garvitsingh14017 months ago
TIme - 0.2 
 
class Geeks { static void printTable (int n)  {           int multiplier=10;           int j=n*10;           while(multiplier>0)           {               System.out.printf("%d ",j);               j=j-n;               multiplier--;           }      System.out.println(); }
}
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.