Home Java Beginners Preparing table of a number by using loop
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Preparing table of a number by using loop

Advertisement
This tutorial will teach you the methods of preparing the table of a given number by using loop condition.

Preparing table of a number by using loop

     

This tutorial will teach you the methods of preparing the table of a given number by using loop condition. As we know the loop statements are used to repeat a statement or process multiple times according to a specified condition. Loop checks certain condition and if it finds the condition is valuable then all the statements written under loop are executed. 

Here we will take a number a=25 of which we have to prepare a table. Define the integer a=25 and b=1 as the initial point. Now apply "while" condition of loop and confine b<=10 as we have to make a table of 25. Again define another integer as c=a*b, this will be the result when we multiply 'a' with 'b'. Here we have to multiply 'a' with 'b' up to 10 times like a*1, a*2....................a*9, a*10. So make define b=b+1 as increment operator. 

Now compile and run the program on the command window. 

Here is the code of the prorgram:

class  PreparingTable{
  public static void main(String[] args) {
  int a=25, b=1;
  System.out.println("the table of "+a+"= ");
  while(b<=10){
  int c = a*b;
  System.out.println(c);
  b = b+1;
  }
  }
}

Download this example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 11, 2008

Related Tutorials

Ask Questions?    Discuss: Preparing table of a number by using loop   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
devi
January 10, 2012
query

how to make a number triangle with java program as the following 1 2 2 3 3 3 4 4 4 4 - - - - - - - - - - -- - - - - - - - - - - - - - n n n n n n
pooja nirmalkar
May 31, 2012
java

i want to make java based application project
sudhakar
July 3, 2013
i done this code

25*1=25 25*2=50 25*3=75 25*4=100 25*5=125 25*6=150 25*7=175 25*8=200 25*9=225 25*10=250 result is like if u add Sentence like System.out.println(a+"*"+b+"="+c);
DMCA.com