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");
}
}

0 Comments
if you have any problem, please let me know