Social Icons

Saturday, 8 February 2014

Program to reverse a number

#include<stdio.h>
#include<conio.h>

void main()
{
long n,rev=0,d;
clrscr();         //to clear screen
printf("\n Enter a number : ");
scanf("%ld",&n);

while(n!=0)
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}

printf("\n The reversed number is : %ld",rev);
getch();         //to stop screen
}



                                                            Output


No comments:

Post a Comment