To find the reverse number of a given number using while loop

 Program:


#include<stdio.h>
#include<conio.h>
void main()
{
    int n;
    unsigned long rev=0;
    printf("Enter any Number :");
    scanf("%d", &n);
    while(n>0)
    {
        rev=(rev*10)+(n%10);
        n=n/10;
    }
    printf("Reverse number of given Number is : %lu", rev);
    getch();
}


Output:

Enter any Number : 786

Reverse number of given Number is : 687




Next Topic        :  

Previous Topic :

No comments:

Post a Comment