Can you provide solution to these problems:
- Multiplication of two numbers using recursion
- String to int conversion using recursion
Can you provide solution to these problems:
Hello @yath17,
I can provide you with a solution.
But, that wouldn’t help you in building the concepts.
So, I will suggest you to try to code these problems yourself.
You can refer to the following hints:
Multiplication of two numbers
Let a and b be the two numbers that you have to multiply.
So,
a*b= a+a+a+…+a(b times)
Example:
1.1. 3*2= 3+3(2 times)=6
1.2. 4*3=4+4+4(3 times)=12
String to int conversion:
2.1. use the formula:
string_to_int=string_to_int*10 +s[i]
2.2. Pass the value of string_to_int and i(index) as 0 to the recursive function. s is the string passed
2.3. then at every recursive pass, i+1 i.e. move to next location.
2.4. pass string_to_int as reference.
2.5. base condition: when you have traversed all the index of the string.
Let me know if you still face any issue.
Hope, this would help.
Give a like if you are satisfied.