0 2 0 2 0 2..
Print this series without using any string approach or conditional construct.
Write in Java.
Answers
Answered by
14
import java.util.Scanner;
public class Series {
public static void main(String[ ] args) {
System.out.print("Enter N - ");
int N = new Scanner(System.in).nextInt( );
for (int i = 0; i < N * 2; i += 2)
System.out.print((i & 2) + " ");
}
}
Similar questions