Skip to content

Instantly share code, notes, and snippets.

@abhijangda
Created July 28, 2013 18:16
Show Gist options
  • Select an option

  • Save abhijangda/6099503 to your computer and use it in GitHub Desktop.

Select an option

Save abhijangda/6099503 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<math.h>
main() {
int a,i,b, output = 0;
printf("Enter a 5 digit number: 12956");
scanf("%d",&a);
if(a>9999 && a<100000)
{
for(i=4;i>=0;i--)
{
b=a/pow(10,i);
a=a-b*pow(10,i);
printf("i=%d a=%d b=%d \n",i,a,b);
if (b != 9)
output += pow(10, i)*(b+1);
}
printf ("out %d\n", output);
}
else
printf("Not a 5 digit number");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment