reversing a number

I have written a code to find reverse of a number and print if if the original and reversed numbers are equal or not .the problem is in the if condition where the first printf is not working at all.
the code is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#include <stdio.h>
#include <conio.h>
int main (void)
{
	int num1;
	int numr=0;
	printf("Enter the three digit number : ");
	scanf("%d", &num1);
	

	while(num1!=0)
	{
		numr=numr*10;
		numr=numr +  num1%10;
		num1=num1/10;

	}

	printf("The reverse of entered number is= %d\n",numr);

	
	if(num1==numr)
		printf("original and reversed numbers are equal\n",num1);
	else 
		printf("original and reversed numbers are not equal\n",num1);

	getch ();
	return 0;
}






as if i enter 121 it still shows the 2nd printf instead of 1st one.please sort out the bug;;!
num1 will always be 0 after the loop.
thankyou please correct this code
1
2
3
4
5
6
7
8
while(num1!=0)
	{
		numr=numr*10;
		numr=numr +  num1%10;
		num1=num1/10;
	
	}(num1=0);
	printf("The reverse of entered number is= %d\n",numr);
For some reason you have a conditional before and after the while loop, take the second one out or make the whole thing a do while loop.
Topic archived. No new replies allowed.