Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Check if a large number is divisible by 11 or not in java
A number is divisible by 11 if the difference between the sum of its alternative digits is divisible by 11.
i.e. if (sum of odd digits) – ( sum of even digits) is 0 or divisible by 11 then the given number is divisible by 11.
Program
import java.util.Scanner;
public class DivisibleBy11 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number :");
String num = sc.nextLine();
int digitSumEve = 0;
int digitSumOdd = 0;
for(int i = 0; iOutput
Enter a number :
121
Given number is divisible by 11
Advertisements
