Skip to content

Instantly share code, notes, and snippets.

@muhammedfurkan
Created December 26, 2020 21:37
Show Gist options
  • Save muhammedfurkan/b79195e9ec6a5decd2483f69006c9c6b to your computer and use it in GitHub Desktop.
Save muhammedfurkan/b79195e9ec6a5decd2483f69006c9c6b to your computer and use it in GitHub Desktop.
reverse number 0 to 99999
#include <stdio.h>
/* Iterative function to reverse digits of num*/
int reversDigits(int num)
{
int rev_num = 0;
while (num > 0)
{
rev_num = rev_num * 10 + num % 10;
num = num / 10;
}
return rev_num;
}
/*Driver program to test reversDigits*/
int main()
{
int num = 4562;
int j = 0;
for (j; j <= 99999; j++)
{
printf("\ninput number = %d\n", j);
printf("reversed number = %d\n\n", reversDigits(j));
}
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment