Using a for loop create a program that will prompts the user for two numbers and then print out a list of even number in between the two given numbers(inclusive), starting from the small number to the big number
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the two numbers smaller and larger: ");
int N=input.nextInt();
int X= input.nextInt();
for(int i=N;i<=X;i++){
if(i%2==0){
System.out.println(i+" ");
}
}
}
}
Comments
Leave a comment