answersLogoWhite

0


Best Answer

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to write A Java program to print number of digits in a given number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C program to fine the largest of 10 given number?

first sort the ten numbers in descending order and print the first number. That will be the largest no


C program to print inverse of a given number?

Inversing of a given Number. suppose we gave input 123456 then the output of the program will be 654321./*mycfiles.wordpress.comC program to print inverse of a given number*/#include#includevoid main(){long int n,rn=0,d=0;clrscr();printf("Enter the number\n\n");scanf("%ld",&n);while(n>0){d=n%10;rn=rn*10+d;n=n/10;}printf("%ld",rn);getch();}


Algorithm for to find sum of individual digits of a positive integer?

enter the number whose digits are to be added num is the given value num=0! k=num%10 sum=sum=k k=num/10 num=k print the sum of the digits


C plus plus program to print sum of uppercase digits?

Good luck. I don't think it is possible, since there is no such thing called upper case digits.


What is the first million digits of pi?

There is a computer program that will print out the value of pi to even more decimal places than that.


How do you print number in digits in c language?

for (first=n; first>=10; first/=10);


How do you prepare a program in basic to display the word and the number of letters in it when is given as input?

10 cls 20 input"enter word";word$ 30 print word$ 40 print len(word$) 50 end this program is for GW BASIC for other BASIC's the line numbers are optional.


C plus plus program to print number patterns?

bghjg


I ned a program to print sum of digits without using while loop?

In python 3 I would write the following (assuming the digits are input by a user): #!/usr/bin/python a = input("Type a number: ") sum = 0 for i in a: #the for next loop performs the function of a while loop with less lines of code. #(My formating keeps getting deleted when I publish this answer. There should always be a tab- strictly speaking four spaces before this line) sum = sum + int(i) sum = str(sum) print("Your number was", a + ". The sum of its digits is" , sum + ".") As you can see, the for next loop iterates through each value in the string "a", and sets its value to "i". For each iteration, the current value of i is added to the variable "sum" until the end of the number is reached. The program then prints the original number, and the sum of its digits.


You are write a program that will read a list of number in the range from 1to n and will print for each number the corresponding term in cantor's enumeration as given no blank line should appear last?

see pages 43-49 in Principles of Program design by M. A. Jackson, 1975


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


How do you solve this program wap to print sum of a digit of an inputed number?

wap to print all the arnstrong no. between 100&1000