wap in java to display the first ten terms of the series - 1,-3,5,-7,9...........
Answers
Answered by
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
78
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
Accountancy,
7 months ago
Physics,
7 months ago