Wednesday, 8 March 2017

C Program to Reverse a number - Beginners

C program to reverse a number is given below:

For example: If a number is 89 then its reverse number will be 98

Program:

#include <stdio.h>
int main()
{
    int x,y=0;
    printf("original number : ");
    scanf("%d",&x);
    while(x!=0)
    {
        y=10*y+(x%10);
        x=x/10;
    }
    printf("after reverse : %d\n",y);
    return 0;
}

OUTPUT:

 


EmoticonEmoticon