Decimal to octal test cases failed?

my code is running correctly for sample input but all test casesare failing in it.

@akarshiarora.17,
Your code has a minor problem,
Instead of everytime multiplying by 10, in the first iteration you need to multiply by 1 then 10, 100, 1000 and so on.
So declare a variable, say, multiplier = 1. and at the end of every iteration, do multiplier*=10.
Also, change rev =rev * 10+p; to rev =rev+multiplier * p;
Here is the updated code: https://ide.codingblocks.com/s/107344

1 Like