Even odd program in Java using WHILE loop

import java.util.Scanner;
public class Even_Odd
{
public static void main(String[] args)
{
int n, i;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the limit: ");
n = sc.nextInt();
i=2;
System.out.print("Lit of even numbers: ");
while(i<=n)
{
System.out.print(i +" ");
i=i+2;
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *