/*A program to print a given integer in reverse order and sum it with original */
#include<stdio.h>
int main() /* use 'long' instead of 'int' if integer is a long integer */
{
int n, reverse = 0,temp;
printf("Enter a number to reverse\n");
scanf("%d",&n);
temp=n;
while( n != 0 )
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
printf("Reverse of entered number is %d\n", reverse);
printf("sum of original number %d and reversed number %d is %d\n",temp,reverse,temp+reverse);
return 0;
}
No comments:
Post a Comment