Write a program which tells whether a number is even or odd. Take a range from 1-50.
PROGRAM:
import java.util.Scanner; class P1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println(); System.out.println("Please Enter Number 1 to 50"); int n =sc.nextInt(); if(n<=50) { if(n%2 == 0) { System.out.println(n+" is even number"); } else { System.out.println(n+" is odd number"); } } else { System.out.println("Sorry! out of limit 1 to 50"); } } }
OUTPUT:
(Visited 502 times, 1 visits today)
Written by: