Thursday, 19 December 2019

Reverse a number in C

#include<stdio.h>
#include<conio.h>
main()
{
int n,r,s=0;
printf("enter the number\n");
scanf("%d",&n);
while(n>0)
{
r=n%10;
s=(s*10)+r;
n=n/10;
}
printf("the reverse is %d\n",s);
getch();
}

No comments:

Post a Comment

Convey your thoughts to authors.