+ 5

C program to find reverse of a number

I develop a code but it does not give the correct output if I enter 000

2nd Dec 2019, 10:07 AM
Geya Shibu
15 Réponses
+ 9
Go through this Code: In this Code ,the number is Reversed and then compare with original number. https://code.sololearn.com/cLcUlmlu081P/?ref=app
3rd Dec 2019, 5:39 PM
ROHIT KANOJIYA
ROHIT KANOJIYA - avatar
+ 8
000 is obviously converted to 0.
2nd Dec 2019, 10:35 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
What are you getting if you input 000?
2nd Dec 2019, 10:09 AM
Avinesh
Avinesh - avatar
+ 3
It depends on your logic. If you want that case also, you have take input 000 as a string or character literals..
2nd Dec 2019, 10:25 AM
Jayakrishna 🇮🇳
+ 3
Geya Shibu If you reverse a number it is okay that 000 return 0. If you use Strings than "000" should return "000".
2nd Dec 2019, 12:12 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
You should write extra case for 000
3rd Dec 2019, 1:19 PM
Pradhumn Sharma
Pradhumn Sharma - avatar
+ 2
👩‍💻ROHIT KANOJIYA👩‍💻 Yes this is the code for reverse of the number. It is correct for all numbers. But check the input 000 The output will be only 0
3rd Dec 2019, 6:09 PM
Geya Shibu
+ 1
Just one 0
2nd Dec 2019, 10:14 AM
Geya Shibu
+ 1
Didn't you get any other better combination of numbers to test your code?
2nd Dec 2019, 10:20 AM
Avinesh
Avinesh - avatar
+ 1
I'm trying to ask whether it is giving right output for other combinations? And share your code first.
2nd Dec 2019, 10:23 AM
Avinesh
Avinesh - avatar
2nd Dec 2019, 10:28 AM
Geya Shibu
+ 1
Okk.👍Thank you
2nd Dec 2019, 10:35 AM
Geya Shibu
0
Why? A program should satisfy every inputs..
2nd Dec 2019, 10:22 AM
Geya Shibu
0
Ohh sorry. Yes it work for other combination. I will share the codeAvinesh
2nd Dec 2019, 10:28 AM
Geya Shibu
0
Geya Shibu When your input is 000. Check the final value that you are printing, it will have only 0. So you will never get the desired result with numeric data types.
2nd Dec 2019, 10:32 AM
Avinesh
Avinesh - avatar