+ 3
Find reverse in C++
i want to find reverse of a number in C++ using numeric data types which return 0 in case of overflow. for example we take int as 4 bytes it stores signed 2147483647 number let we reverse this number it becomes 7463847412 it beyonds the range of int in this case it should return 0 how to handle it
10 Respostas
+ 2
here is my try
Here is a likely bruteforce
see this
https://code.sololearn.com/curvKsv91799/?ref=app
+ 4
https://code.sololearn.com/cnBXWW4YriE8/?ref=app
+ 3
great @Azam, but unlike Maria's code, it doesn't work with negative numbers just like mine
https://code.sololearn.com/W0BN8HZm8F1k/?ref=app
+ 3
ohhh you use an array in JS unlike Cpp
+ 2
I input 2147483647
answer is -1126087180
in Maria's code
@Nomeh
+ 2
yeah it's quit easier and shorter with arrays and loops.
...I think the same syntax should work with other languages like (C++, Java, C#, Swift etc)
+ 2
yeh. . I know with arrays but I want with numerous Data type in C++.
+ 2
now Run code for negative values
+ 1
thanks @ace