source file name: Reverseno.C
If a five digit number is input through keyboard. Write a program to obtain reversed number and to determine whether the original and reversed numbers are equal or not.
void main()
{
int n,d1,d2,d3,d4,d5;
int revno,temp;
//clrscr();
printf("\n enter any no \n");
scanf("%d",&n);
temp=n;
d1=n%10;n=n/10;
d2=n%10;n=n/10;
d3=n%10;n=n/10;
d4=n%10;n=n/10;
d5=n%10;
revno=d1*10000+d2*1000+d3*100+d4*10+d5;
printf("\n Original no: %d Reverse no: %d",temp,revno);
if(revno==temp)
printf("\n both numbers are equals");
else
printf("\n both numbers are not equals");
getch();
}
output:
0 Comments
Post a Comment