Tuesday, 10 January 2012

Reverse of a Number

/* write a c program to reverse a number */

#include<stdio.h>
#include<conio.h>

void main()
{
    int n,rev=0;
    clrscr();
    printf("Enter the number::\n");
    scanf("%d",&n);
    while(n!=0)
    {
        rev=rev*10;
        rev=rev+n%10;
        n=n/10;
    }
    printf("Reverse of the given number is= %d",rev);
    getch();
}


Output of program:
reverse number

No comments:

Post a Comment