Last test case is not passing plz tell the mmistake.
Tell the mistake pls , 1 test case not passing
your approach is incorrect bcz if the input is:
sb = 5
db = 6
sn = 1000
then your code does not give any output.
You can use this function to implement conversion of any to any:
int conversion(int num, int sb, int db){
// Any Base to Decimal
int ans = 0;
int mult = 1;
while(num != 0){
int rem = num % 10;
ans = ans + rem * mult;
mult = mult * sb;
num = num / 10;
}
// Refresing the variables
mult = 1;
num = ans;
ans = 0;
//Decimal to Any number
while(num != 0){
int rem = num % db;
ans = ans + rem * mult;
mult = mult * 10;
num = num / db;
}
return ans;
}
So there is no need for conversions like hexadecimal to octal , octal to binary etc?
Because the code u have shared has code for conversion from decimal to any and any to decimal, Coversion from decimal to hexadecimal also includes A to F numbers and hexadecimal to any number must also contain a logic for numbers containing A to F so will the code shared by u work for all cases?
It worked sir , thanks for help i think its test cases doesnt have numbers including A to F.
yes, you have to check whenever you are converting decimal to hexadecimal.
I hope now your doubt is clear,
and if you have any doubt, then feel free to ask…