what is source number system base and destination number system base.
What is sb and db?
hi @akki56756_bab14f919dbad123
this problem is based on the concept of different number systems (binary, decimal, octal, hexadecimal, or in any other base…)
The Logic is to First conver the corresponding given source base to decimal and then convert the decimal base to Given destination base.
In short the Question is Any Base to Decimal and then Decimal to Any Base.
u can refer this -->
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;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.