To find the Reverse Number of a given number by using for loop

 Program:

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

Output:

Enter any Number : 756
Reverse Number of given Number is : 657


Next Topic        :  

Previous Topic :

No comments:

Post a Comment