13,739,685 members
See more:
You are given a positive integer N. You have to reverse the digits of
N. Let us denote this number by R. You must output N+R.

Input
-----
A positive integer.

Output
------
The sum of the integer and the reverse of the integer.

Sample Input 1
--------------
547

Sample Output 1
---------------
1292

Explanation
-----------
The reverse of 547 is 745. The sum of 547 and 745 is 1292.

What I have tried:

plzz answer it fast as possible
Posted 16-Sep-17 22:55pm
Updated 29-Aug-18 23:06pm

## Solution 1

Quote:
plzz answer it fast as possible
It doesn't work that way. You have to try harder to solve the problem and ask here specific questions whenever you are stuck.

Hint: the rightmost (less significant) digit of the decimal number `N` is `(N%10)`.

(As an alternative you could convert the number to a string, reverse the string and convert it back to a number).

## Solution 2

We do not write code for you and your homework, this forum is for people who have genuine problems not people who are lazy and can't be bothered to even try.

## Solution 4

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

## Solution 3

#include<stdio.h>
void main()
{
int n,r,s,rm,n1;
scanf("%d",&n);
n1=n;
s=0;
while(n>0)
{
rm=n%10;
s=s*10+rm;
n=n/10;
}
printf("%d",s+n1);
}
Patrice T 17-Sep-17 5:39am

Just giving a full blowup solution to homework is defeating its purpose and prevent learning.

## Solution 5

#include<stdio.h>
void main()
{
int n,a,r,s=0;
printf("enter number:");
scanf("%d",&n);
a=n;
while(n) //executes until n!=0
{
r=n%10;
s=s*10+r;
n/=10;
}
printf("\nsum is %d:",a+s);
}
v2
Dave Kreskowiak 11-Jul-18 15:51pm

Doing some's homework for them is frowned up around here. I suggest you don't do it again.

Oh, and you're only a year late. I seriously doubt the OP is still waiting for someone to do his/her work for them.

## Solution 6

#include <stdio.h>

int main()
{
int n,t,r=0,t1,sum;
printf("enter the number between 1 to 999\t");
scanf("%d",&n);
if(n<1||n>999)
{
printf("invalid input");
}
else{
printf(" number is %d\t",n);
t=n;
while(t>0)
{ t1=t%10;
r=r*10+t1;
t=t/10;
}
printf(" \nreverse is %d",r);
sum=n+r;
}
}
CHill60 27-Jul-18 5:57am

"Just giving a full blowup solution to homework is defeating its purpose and prevent learning."
"Doing some's homework for them is frowned up around here. I suggest you don't do it again."
"Oh, and you're only a year late. I seriously doubt the OP is still waiting for someone to do his/her work for them."

## Solution 7

```#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,sum=0,rev=0;
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum=sum+r;
rev=rev*10+r;
n=n/10;
}
printf("%d%d",sum,rev);
getch();
}```
v3
Patrice T 31-Jul-18 11:29am

1 year too late and the code is wrong !
If you want to help, try to focus on actual questions.

## Solution 8

#include<stdio.h>
int main()
{
int n,rev=0,sum=0,temp,rem;
printf("enter the number n\n");
scanf("%d",&n);
temp=n;
while(n>0)
rem=n%10;
rev=rev*10+rem;
n=n/10;
printf("reverse number=%d\n",rev);
sum=temp+rev;
printf("Sum=%d\n",sum);
return 0;
}
v3
Dave Kreskowiak 12-Aug-18 21:00pm

This question is over a year old and it was to have someone do their homework for them. THAT DOES NOT HELP THE PERSON DEMANDING THE CODE.

## Solution 9

#include<stdio.h>
void main(){
int n,y,sum=0;
printf("\n enter any positive integer:");
scanf("%d",&n);
y=n;
while(n!=0){
sum=(sum*10)+(n%10);
n=n/10;
}
printf("sum of %d and %d is %d",y,sum,sum+y);
}
v3
CHill60 13-Aug-18 3:58am

## Solution 11

#include<stdio.h>
void main()
{
int R=0,N,n,sum,rev;
printf("Enter number ");
scanf("%d",&N);
n=N;
while(n!=0)
{
rev=n%10;
R=R*10+rev;
n=n/10;
}
sum=R+N;
printf("%d",sum);
}
CHill60 30-Aug-18 8:34am

Doing someone's homework for them is not helpful.
Just dumping code is not helpful.
Read all of the solutions and all of the commments to those solutions before posting your own solution to prevent just repeating what someone else has already done.

Top Experts
Last 24hrsThis month
 Jason Gleim 120 OriginalGriff 100 CPallini 60 Richard MacCutchan 45 Dave Kreskowiak 45
 OriginalGriff 5,936 Richard MacCutchan 2,199 Patrice T 1,672 CPallini 1,384 Dave Kreskowiak 1,270