Page 289 - CA_Blue( J )_Class9
P. 289

You will get the following output:
                        Enter a number whose multiplication table will be generated : 5
                        5 x 1 = 5
                        5 x 2 = 10
                        5 x 3 = 15
                        5 x 4 = 20
                        5 x 5 = 25
                        5 x 6 = 30
                        5 x 7 = 35
                        5 x 8 = 40
                        5 x 9 = 45
                        5 x 10 = 50

                                                        VARIABLE DESCRIPTION
                           NAME               DATATYPE                           DESCRIPTION
                       n                int                   Accept number
                       i                int                   Loop variable

                                 Programs based on printing simple series, summation of simple series.
                  Program 12
                                 0, 1, 1, 2, 3, 5, 8, 13, 21, … nth term (Fibonacci Series)
                   1      class Fibonacci                                      //class name
                   2          {

                   3              public static void main(int n)
                   4              {

                   5                  int a, b, c, i;                          //Variable description
                   6                  a=0;                                     // Initializing variable

                   7                  b=1;
                   8                  System.out.println("Fibonacci Series upto "+n+"th term : ");

                                                                                      st
                   9                  System.out.print(a+", "+b); //Printing of 1  two numbers of the series
                  10                  for(i=3;i<=n;i++)                        //Loop Variable

                  11                  {
                  12                      c=a+b;

                  13                      System.out.print(", "+c);   //Printing of next number
                  14                      a=b;

                  15                      b=c;
                  16                  }

                  17              }
                  18          }







                                                                                             Internal Assessment  287
   284   285   286   287   288   289   290   291   292   293   294