“Nomor ganjil di java” Kode Jawaban

Bagaimana cara memeriksa nomor ganjil di java

// Java Program to Check if Given Integer is Odd or Even
// Using Bitwise AND
 
// Importing required classes
import java.util.*;
 
// Main class
public class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
 
        // Declare and initializing integer variable
        int n = 91;
 
        // Condition Check
        // Bitwise AND of any odd number by 1 gives 1
        if ((n & 1) == 1) {
 
            // Print statement
            System.out.println("Number is Odd");
        }
        else {
 
            // Print statement
            System.out.println("Number is Even");
        }
    }
}
Delta Sierra

periksa apakah nomornya ganjil java

if (num % 2 == 0)
{
	// even number
}
else
{
	// odd number
}
CompSciGeek

Nomor ganjil di java

import java.util.Scanner;

public class Exam{
	public static void main(String[] args){
    
		Scanner scan = new Scanner(System.in);
        System.out.println("Enter number");
		int input = scan.nextInt();
		if(input % 2 != 0){
        	System.out.println(input + " is odd");
	      }
		else
			System.out.println(input + " is even");
	}
}	
Steven2003

Jawaban yang mirip dengan “Nomor ganjil di java”

Pertanyaan yang mirip dengan “Nomor ganjil di java”

Lebih banyak jawaban terkait untuk “Nomor ganjil di java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya