Program: Write a program to list all even numbers less than or equal to the
number n. Take the value of n as input
from user.
Code:
Code:
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class EvenNumber {
- /**
- * @param args
- * @throws IOException
- * @throws NumberFormatException
- */
- public static void main(String[] args) throws NumberFormatException, IOException {
- // TODO Auto-generated method stub
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter no :");
- int no=Integer.parseInt(br.readLine());
- for(int i=0;i<=no;i++)
- if(i%2==0)
- System.out.println("Even No :"+i);
- }
- }
No comments:
Post a Comment