Monday, June 18, 2012

To reverse the given number


/* To reverse the given number */
#include<stdio.h>
#include<conio.h>
void main()
{
  int num,n1,a,rev=0;
  clrscr();
  printf("Enter the number: ");
  scanf("%d",&num);
  n1=num;
  while(num!=0)
  {
    a=num%10;
    rev=rev*10+a;
    num=num/10;
  }
  printf("\n\nReverse of given number %d --> %d",n1,rev);
  getch();
}
 
OUTPUT
Enter the number: 4297
 
Reverse of given number 4297 --> 7924
 
 
 
 
 
 
 
 
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.