#include <stdio.h>
#include <stdlib.h>
#define n 50
void function(int);
int main()
{
puts("number");
int n;
scanf("%d", &n);
function(n);
}
void function(int n)
{
int temp = n;
int count;
for(count = 0; temp > 10; count++) //divides the number by 10 until only one digit remains, so as to find the first digit. also, the count variable is counting how many times this division is required, which essentially is counting how many digits.
{
temp = temp / 10;
}
count++;
printf("number of digits = %d\n", count);
printf("Digit 1 = %d\n", temp);
int c2;
int temp2 = temp;
for(c2 = 0; c2 <= count + 1; c2++); //multiplying the number by 10 to the power of the number of digits
{
temp *= 10;
}
temp *= 10;
int result = n - temp;
printf("%d - %d = %d\n", n, temp, result);
}
|