I'v been asked to write the function that print the multiplication table until x*y using only recursion.
the function call will be mult(x,1,y);
void mult(int x, int base, int y).
Have any idea how to slove it?
This is a discussion on Multiplication table using only recursion within the C Programming forums, part of the General Programming Boards category; I'v been asked to write the function that print the multiplication table until x*y using only recursion. the function call ...
I'v been asked to write the function that print the multiplication table until x*y using only recursion.
the function call will be mult(x,1,y);
void mult(int x, int base, int y).
Have any idea how to slove it?
The rule is as simple as this : You post your try and then you get feedback![]()
Code - functions and small libraries I use
__________________________________________________ __________________________________________________ ______________
It’s 2013 and I still use printf() for debugging.
My idea was : to print (x/x)*base each row
And then to promote base.
printf("%2d ",base);
if(base==y) return;
mult_table(x,++base,y);
my problem is when i stop recursion it back with base =5 and i didnt found how to use it.
Last edited by Oleg Suharevich; 01-12-2013 at 09:35 AM.
Post your code in code tags next time, like this
[code]/*your program*/[/code]
I do not understand your problem :/
Code - functions and small libraries I use
__________________________________________________ __________________________________________________ ______________
It’s 2013 and I still use printf() for debugging.
Ill.
My problem is to print each row after the first one .
I print the first row 1-10
but when the recursion is start to return it back with base 10 (in case 10*10) and i cant use that base to print the next row.
Have no idea how I need to make it.
Any problem which can be solved iteratively can also be solved using recursion. Why not make the iterative version first and then try to convert it to a recursive version?
for x = 1 to 10
for y = 1 to 10
...
end for
end for
I know , thank you