khalequzzaman17

Java Program from the Book

Sep 24th, 2021 (edited)
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. Fibonacchi numbers:
  2.  
  3. public class fibo{
  4.  
  5.      public static void main(String []args){
  6.         int f0=0,f1=1,f;
  7.         System.out.println("First 10 fibonacci numbers are:\n");
  8.         for  (int i=1; i<=10;i++)
  9.         {
  10.             f=f0+f1;
  11.             System.out.print(" "+f+" ");
  12.             f1=f0;
  13.             f0=f;
  14.         }
  15.      }
  16. }
  17.  
  18. Array:
  19.  
  20. public class array{
  21.  
  22.      public static void main(String []args){
  23.          int mark[]={23,58,59,27,92,13,45};
  24.          for(int i=0; i<6; i++)
  25.          {
  26.              System.out.println("Mark[" +i+"]="+mark[i]);
  27.          }
  28.      }
  29. }
Add Comment
Please, Sign In to add comment