Thursday 3 October 2013

Finding Reverse of a Number using C

#include<stdio.h>
main()
{
int num,rem,rev=0;
printf("\n(There is) none worthy of worship except Allah(Subhanahu wa ta'ala).Muhammad(Sallallahu alayhi wasallam) is Messenger of ALLAH(Subhanahu wa ta'ala).\n");
printf("Enter the number:\t");
scanf("%d",&num);
while(num>0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
printf("Reverse of the given number is %d \n",rev);
}

No comments:

Post a Comment