At the end of this page, you will see the output of below program. Below program will reverse the any given number as input by the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> int main() { int num, rem, rev = 0; printf("\nEnter any Number: "); scanf("%d", &num); while (num >= 1) { rem = num % 10; rev = rev * 10 + rem; num = num / 10; } printf("\nReversed Number is: %d", rev); return (0); } |
Output
1 2 | Enter any Number: 987 Reversed Number is: 789 |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: c programs, c tutorials, how to write a program in c to reverse a number, what is c programming, write a program in c to reverse a number