Sunday, 2 March 2014

Write a C program to reverse a number.

#include<stdio.h>

main()
{
    int num,rev=0,rem;
    printf("\nEnter a number=");
    scanf("%d",&num);
    while(num)
    {
        rem=num%10;
        rev=rev*10+rem;
        num/=10;
    }
   
    printf("\nThe reverse =%d",rev);
}

No comments:

Post a Comment