Java program to check if an integer is divisible or not

In this example we will show user how to write  a java programming language to check whether entered integer is multiple or not using if and else statement.
For Example, we have initialised two variables such as a=96 and b=24. If 96%24 is equal to zero than it will show 96 is multiple of 24 otherwise not. 

Java Program to check if Number is Multiple or Not
class Multiple
{
public static void main(String args[])
{
int a=96,b=24;
System.out.println("Integer 1 : " + a);
System.out.println("Integer 2 : " + b);
if(a%b == 0)
System.out.println(a + " is a multiple of " + b);
else
System.out.println(a + " is a not multiple of " + b);
}}
OUTPUT:
Integer 1: 96
Integer 2: 24
96 is a multiple of 24

tags : java , java programs , program of c++ , c programming , codecamp

Post a Comment

Previous Post Next Post