Skip to main content

Posts

Showing posts from June, 2017

Multiplication table using recursion only in C++

Problem Statment: Write a recursive function to print a multiplication table from M to N. Where M and N are both non-negative integer. # include < iostream > void do_table ( int const m , int const n , int const start ) { if ( m > n ) std :: cout < < std :: endl ; else { std :: cout < < m < < " * " < < start < < " = " < < m * start < < " \t " ; do_table ( m + 1 , n , start ) ; } } void multiplication_table ( int const m , int const n , int const start ) { if ( start > 10 ) std :: cout < < std :: endl ; else { do_table ( m , n , start ) ; multiplication_table ( m , n , start + 1 ) ; } } int main ( void ) { multiplication_table ( 1 , 10 , 1 ) ; return 0 ; }     Output