1.

Write a program in java to print the sum of the pattern: s=1/2+3/4+5/6.........+19/20

Answer»

CLASS Series

{

   PUBLIC STATIC  void main()

   {

       double a=1.0,b=2.0;

       double s=0.0,s1=0.0;

       System.out.println("the TERMS are");

       for(INT i=1;i<=10;i++)

       {

           s1=(a/b);

           System.out.println(s1);

           s=s+s1;

           a+=2;

           b+=2;

       }

       System.out.println("");

       System.out.println("the sum is "+s);

   }

}



Discussion

No Comment Found