Answers for "count the number of digits in an integer in java"

0

count the number of digits in an integer in java

import java.util.Scanner;
public class CountingDigitsInInteger {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int count = 0;
      System.out.println("Enter a number ::");
      int num = sc.nextInt();
      while(num!=0){
         num = num/10;
         count++;
      }
      System.out.println("Number of digits in the entered integer are :: "+count);
   }
}
Posted by: Guest on September-30-2020

Code answers related to "count the number of digits in an integer in java"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language