Print/show table of a desired number with Recursion
#include<iostream>
using namespace std;
int table (int number , int n); // prototype
int main( ){
int number ;
cout<<"Please enter Number for which you want to print table : ";
cin>>number;
table(number , 10); // function calling and passing number and
//numbers of multiples(in this case up to 10th
// multiple)
return 0;
}
int table (int number , int n)
{
if(n == 1)
{
cout<<number<<" * "<<n<< " = "<<number*n<<endl;
return 1;
}
table(number , n-1); // recursive calling
cout<<number<<" * "<<n<< " = "<<number*n<<endl;
return 1;
}
.....................................................................................................................................................................
** Run this program on system and print table
#include<iostream>
using namespace std;
int table (int number , int n); // prototype
int main( ){
int number ;
cout<<"Please enter Number for which you want to print table : ";
cin>>number;
table(number , 10); // function calling and passing number and
//numbers of multiples(in this case up to 10th
// multiple)
return 0;
}
int table (int number , int n)
{
if(n == 1)
{
cout<<number<<" * "<<n<< " = "<<number*n<<endl;
return 1;
}
table(number , n-1); // recursive calling
cout<<number<<" * "<<n<< " = "<<number*n<<endl;
return 1;
}
.....................................................................................................................................................................
** Run this program on system and print table