Math, asked by PraneetiChowdhury, 2 months ago

White
a
program in Java to print the
following series:
1-12 +123 - 1234.​

Answers

Answered by kingsmen99
2

import java.util.*;

class Series

{

public static void main(String args[ ])

{

int i, k = 0, s = 0;

Scanner sc = new Scanner(System.in);

for(i = 0; i < = 4; i ++)

{

if ( i % 2 != 0)

k = (k * 10) + i;

System.out.print('+' + k);

else

k = -1((k * 10) + i);

System.out.print('-' + k);

}

}

}

Similar questions