answersLogoWhite

0


Best Answer

Count them unless the number has a recurring ending.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find most occurring digit in a number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you separate digits in c plus plus?

Repeatedly divide the number by 10 and store the remainder (the modulo). By way of an example, if the number were 12345: 12345 % 10 = 5 (first digit) 12345 / 10 = 1234 1234 % 10 = 4 (second digit) 1234 / 10 = 123 123 % 10 = 3 (third digit) 123 / 10 = 12 12 % 10 = 2 (fourth digit) 12 / 10 = 1 (fifth digit) This algorithm forms the basis of number reversals. The following function demonstrates the most efficient way of reversing any number in the range -2,147,483,648 to 2,147,483,647, inclusive. int RevNum( int num ) { const int base = 10; int result = 0; int remain = 0; do { remain = num % base; result *= base; result += remain; } while( num /= base); return( result ); }


Develop a program that reads a floating point number and then replace the right most digit of the integral part of the number?

/* program without if statement */ #include<stdio.h> #include<conio.h> void main() { int a,c; float b; clrscr(); printf("Enter the value \n"); scanf("%f",&b); a=c; c=a%10; printf("the right most digit is %d",c); getch(); }


What is a c program to reverse a five digit number?

#include <stdio.h> int main(void){ // Local Declerations int intNum; int midDigit; // Statements printf("Enter a 5 digit integral number: "); scanf("%d", &intNum); //the assignment expression below is used to calculate the mid digit oneDigit = (intNum % 1000) / 100; printf("\nThe middle digit is: %d", oneDigit); return 0; }


Write a shell script to print given number in reverse order in Unix?

# Algo: # 1) Input number n # 2) Set rev=0, sd=0 # 3) Find single digit in sd as n % 10 it will give (left most digit) # 4) Construct revrse no as rev * 10 + sd # 5) Decrment n by 1 # 6) Is n is greater than zero, if yes goto step 3, otherwise next step # 7) Print rev # if [ $# -ne 1 ] then echo "Usage: $0 number" echo " I will find reverse of given number" echo " For eg. $0 123, I will print 321" exit 1 fi n=$1 rev=0 sd=0 while [ $n -gt 0 ] do sd=`expr $n % 10` rev=`expr $rev \* 10 + $sd` n=`expr $n / 10` done echo "Reverse number is $rev"


WAP that initialize an integer and display whether it is single digit two digit three digit or more than three digits?

Please note that the answer below is the most expandable answer. By this I mean that it can be easily changed to display the output given for any number of digits in a number. There are far simpler solutions which do not require any explanation, but are useless in an evolving setting. To answer this question, we need to look at the Math.log10 function. Ignoring the possible anomalous results of this function (check the current Java API to find out what other results are possible), we can find the number of digits in a number by using: (log10(n) + 1). If n is equal to the value 10^m for a value m, then the function will return m. That is to say, if n is equal to 10, then the result of the function will be 1, since 10^1 = 10. Likewise, if n is equal to 100, then the result of the function will be 2, since 10^2 = 100, and so forth. If you look at the numbers in between, you will find the function returns a decimal result. log10(99) = 1.9956, for example. This means that the range of answers you will get for the values [10,99] will return the range of answers from [1.0,2.0). The same can be found looking at the range of values [100,999] which return in the range [2.0,3.0). From this we find that the function log10 always returns either an integer or a fractional value which will always be at most 1.0 less than the number of digits in the number sent to it. In either case, if we simply truncate it (cast the double as an int) and add 1, we come up with our getNumDigits function. int getNumDigits(int n) { return ((int) Math.log10(n)) + 1; } And to finish up your question, we can add in another method to deal with the results. // we're assuming the number n comes from somewhere else, // whether hard-coded or passed as input to the program void displayNumDigits(int n) { switch(getNumDigits(n)) { case 1: System.out.println("One digit"); break; case 2: System.out.println("Two digits"); break; case 3: System.out.println("Three digits"); break; default: System.out.println("More than three digits"); } }