count the number of digits provided in a number-programmingraja

 Aim:-Write a program to count the number of digits provided in a number.


Software used:- Notepad, Command prompt


Program coding:-


class digit

        public static void main(String args[]) 

        { 

  

int c=0,n;

n = Integer.parseInt(args[0]);

do

{

n=(int)n/10;

c++;

}

while(n>0);

      System.out.println("The number contains"+  c+" digits"); 

   } 

}

Output:-



Post a Comment

0 Comments