//Even nos. from 1 up to given range
import java.util.Scanner;
class Range_even {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a no:");
int n=sc.nextInt();
if(n<1)
System.out.println("INVALID INPUT");
else
{
for(int i=2;i<=n;i=+2)
System.out.println(i);
}
}
}
import java.util.Scanner;
class Range_even {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a no:");
int n=sc.nextInt();
if(n<1)
System.out.println("INVALID INPUT");
else
{
for(int i=2;i<=n;i=+2)
System.out.println(i);
}
}
}
No comments:
Post a Comment