0 2 0 2 0 2..
Print this series without using any string approach or conditional construct.
Write in Java.
Share
0 2 0 2 0 2..
Print this series without using any string approach or conditional construct.
Write in Java.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
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) + " ");
}
}