Computer Science, asked by aarshi5, 1 year ago

wap in java to display the first ten terms of the series - 1,-3,5,-7,9...........

Answers

Answered by samless123pcq81z
4

Here is the program :

public class xsa

{

       void xyz() {  

           int a = 1 , b = - 3 ;  

           for ( int i = 1 ; i <= 10 ; i++) {  

                if( i % 2 == 0 ) {  

                    System.out.println(b) ;  

                    b = b - 4 ;  

                   }  

                else {  

                    System.out.println(a) ;  

                    a = a + 4 ; }  

                   }  

               }  

   

   

}

Answered by AestheticSoul
78

\huge\sf\red{Programme~:-}

class series

{

public void display ( )

{

int a = 1;

for (int i = 1; i < = 19; i = i + 2)

{

System.out.print( a * i + " , " );

a = a * -1;

}

}

}

Similar questions