write a program using bluej to print all the odd numbers between X and Y. value of x and y must be taken by the user.
Share
write a program using bluej to print all the odd numbers between X and Y. value of x and y must be taken by the user.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
एक्स और वाई के बीच सभी विषम संख्याओं को प्रिंट करने के लिए ब्लूज का उपयोग करके एक प्रोग्राम लिखें। x और y का मान उपयोगकर्ता द्वारा लिया जाना चाहिए।
Answer:
Programiz
Search Programiz
Java Program to Check Whether a Number is Even or Odd
In this program, you'll learn to check if a number entered by an user is even or odd. This will be done using if...else statement and ternary operator in Java.
To understand this example, you should have the knowledge of the following Java programming topics:
Java if...else Statement
Java Scanner Class
Example 1: Check whether a number is even or odd using if...else statement
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