#include<stdio.h>
#include<conio.h>
void main()
{
int n,d[10],i,k,s;
clrscr();
printf("enter the number..:");
scanf("%d",&n);
for(i=0,t=n;t>0;i++)
{
d[i]=t%10;
t=t/10;
}
k=i;
s=d[0];
for(i=1;i<k;i++)
{
if(d[i]<s)
s=d[i];
}
printf("\n The smallest digit is...%d",s);
getch();
}
#include <stdio.h>
int main()
{
int input;
printf ("Enter a number ");
scanf ("%d", &input);
int digit = 0;
while (1)
{
if ( (input % 10 > 0) (input /10 > 0) )
{
digit += input % 10;
input /= 10;
} else if ( digit > 9 )
{
input = digit;
digit = 0;
}
else
{
break;
}
}
printf("Your input is condensed to %d \n\n", digit);
return 1;
}
// returns the largest digit of num in the given base (default is base 10, decimal)int largest_digit (int num, int base=10) {
int current, digit;
current = num%base; // store least-significant digit (current largest)
while (num/=base) { // repeat until num is zero
digit=num%base; // store least-significant digit
if (current<digit) { // compare
current=digit; // update current largest
}
}
return current;
}
Example usage:
int main (void) {
int d1 = largest_digit (42); // 4
int d2 = largest_digit (123); // 3
int d3 = largest_digit (741863); // 8
int d4 = largest_digit (0xABCD, 16); // 13
return 0;
}
Note that although 13 has two digits, 13 is the decimal value of D, the largest digit in 0XABCD.
345
160 and 192.
The tricky part is getting the individual digits. There are basically two ways to do this: 1) Convert the number to a string, and use string manipulation to get the individual digits. 2) Repeatedly divide the number by 10. The digit is the remainder (use the "%" operator). To actually get the highest digit, initially assume that the highest digit is zero (store this to a variable, called "maxDigit" or something similar). If you find a higher digit, replace maxDigit by that.
Count them unless the number has a recurring ending.
The greatest number is infinity.
Yes
syntax error
As 1 million is the lowest 7-digit number and also the square of one thousand, the number you seek is the square of 999, which I'm sure you can calculate!
find the diagonal method of two digit number and three digit number
It is easier to find the lowest common number, then getting the largest multiple of that that is under 10000. The LCM is 4680, x2 is 9360.
The lowest common multiple of 5 and 9 is 45 and 11 times 45 is 495 which is the greatest 3 digit number divisible by 5 and 9
The last digit is always the estimated digit in a number
"If the units digit and the hundreds digit of the number 513 were reversed..." 315 'find the sum of the original number and the new number." 513+315=828
It is 63.
first you look at the first number tell what that number is then you just find the first digit.
It is 99,899,999.
The units digit of a two digit number exceeds twice the tens digit by 1. Find the number if the sum of its digits is 10.
50