write a Java program to print following series.
Attachments:
Answers
Answered by
0
Answer:
Explanation:
About 22,40,00,000 results (0.65 seconds)
Print Series 1, -3, 5, -7, …………n terms in Java.
public class OddSeries.
public static void main(String args[])
int n = sc.nextInt();
int i = 1, c, f = 1; // i for odd nos, c for counter, f for flag.
for (c = 1; c <= n; c++) {
if (f % 2 == 0) {
} else {
} //Loop ends.
Similar questions