Computer Science, asked by falgunisarkar1980, 9 months ago

wap in java to enter two numbers 'a and b' and display all the even numbers till 'a and b'​

Answers

Answered by Anonymous
1

Answer:

import java.util.Scanner;

public class EvenOdd {

   public static void main(String[] args) {

       Scanner reader = new Scanner(System.in);

       System.out.print("Enter a number: ");

       int num = reader.nextInt();

       if(num % 2 == 0)

           System.out.println(num + " is even");

       else

           System.out.println(num + " is odd");

   }

}

Answered by Narutsu
1

import java.util.*;

class even

{

public static void main()

{

Scanner s=new Scanner(System.in);

System.out.println("Enter a and b");

int a=s.nextInt();

int b=s.nextInt();

for(int i=a;i<=b;i++)

{

if(i%2==0)

{

System.out.println(i);

}

}

}

}

Similar questions