Created
December 26, 2020 21:37
-
-
Save muhammedfurkan/b79195e9ec6a5decd2483f69006c9c6b to your computer and use it in GitHub Desktop.
reverse number 0 to 99999
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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