C Program Reverse the Digits
/* Write a program to reverse sequence of digit. */
#include <stdio.h>
int main(void) {
int n,r,sum=0;
printf("Enter Any Number : ");
scanf("%d",&n);
while(n>0)
{
r = n % 10;
sum = (sum * 10)+r;
n = n / 10;
}
printf(" Reverse = %d",sum);
return 0;
}
#include <stdio.h>
int main(void) {
int n,r,sum=0;
printf("Enter Any Number : ");
scanf("%d",&n);
while(n>0)
{
r = n % 10;
sum = (sum * 10)+r;
n = n / 10;
}
printf(" Reverse = %d",sum);
return 0;
}
Comments
Post a Comment