Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

c program to add 1 with each digits in recursion

Amir PazAmir Paz israel Member Posts: 1

For each digit, get the next digit, for 9, the number 0

123456=234567
999=0
123496=234506

I'm stuck writing the program and have no outlet Anyone can help me?!


include <stdio.h>

int main()
{
int n, c;
int result;
printf(" plese enter n ");
scanf("%d", &n);
result = ontodigit(n,1);

printf("Sum = %d\n", result);
}

int ontodigit( int n)
{
int temp=1,x=1;
if (n < 10)
return n;
else
{
temp=((ontodigit(n/10 )+1)%10);

x= temp+(x*10);

}
return x;

}

Sign In or Register to comment.