10's complement

#include<stdio.h>
int tensComplement(int n)
{
if(n>10)
return(10*tensComplement(n/10)-n%10);
else if(n<10)
return(10-n);
else
return 90;
}

int main()
{
printf("%d\n",tensComplement(1000));
return 0;
}

Today I learned it.

No comments:

Post a Comment

తెలుగులో వ్రాయడానికి http://www.google.com/ime/transliteration/ ఉపయోగించండి.