WAP to check whether a number is divisible by 7 or not.

8 months ago
OOP Java

Compile code:

class Divisibleby7ornot{
public static void main(String[] args) {
        
      int n=14,r1;
      r1=n%7;
      if(r1==0)
     System.out.println("Number is exactly divisible by 7: "+n);
     else
     System.out.println("Number is not divisible by 7: "+n);
    
   }
}

 

Output:

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions

Top