Page 213 - CA_Blue( J )_Class9
P. 213

8              }
                   9          }

                  10      }

                 You will get the following output:
































                  Program 2      Write a program to display the table of a number.

                   1      import java.util.*;

                   2      class PrintTable
                   3      {

                   4          public static void main(String args[])
                   5          {

                   6              Scanner input = new Scanner(System.in);
                   7              System.out.println("Which table do you want? \nAns: ");

                   8              int num = input.nextInt();
                   9              for(int i = 1; i <= 10; i++)

                  10              {
                  11              System.out.println(num + " X "+i+" = " + (i * num));
                  12              }

                  13          }

                  14      }







                                                                                       Iterative Constructs in Java  211
   208   209   210   211   212   213   214   215   216   217   218