# This artical explains how can reverse a number using c programming

 Category: C Programming Tags:

### Lets see how to reverse a number in c

see this code shown below:
`#include<conio.h>#include<stdlib.h>#include<stdio.h>main(){  int num,d,r,rev;  clrscr();             //it is in conio.h library   printf("Enter any number between 9 and 100\n");  scanf("%d", &num);  if(num<9 || num>100)  {    printf("wrong input\n");    getch();               //it is in conio.h library     exit(0);              // it is in stdlib.h librery  }  r=num%10;              // reminder  d=num/10;              // the leftmost digit  rev=r*10+d;           // reverse of the number  printf("reverse number is %d \n", rev);  getch();}`
Output:-
Enter any number between 9 and 100
75
reverse number is 57

Explanation:-
exit(0) is used to terminate the program if user enters the wrong number
if he enters 75 then:
r = num%10        =>  r = 75%10 = 5
d = num/10         =>  d = 75/10 = 7
rev = r*10+d       =>  rev = 5*10+7 = 57

 Like 0 People
Published on 21 May 2013 Nikhil Joshi Ceo & Founder at Dotnetlovers Atricles: 158 Questions: 16 Given Best Solutions: 16 * like if u find it good :)
Like 3 People on 23 May 2013 :) :) GOOD
Like 1 Person on 23 May 2013 nice article .. thank you
Like 1 Person on 23 May 2013

Login via:   x 