Write function in C++ that will calculate table of a number in C++. Number must be passed from calling function as an argument to function parameters.
//C++ function to calculate table of number using function with parameters
#include<iostream>
using namespace std;
//table function declaration
void table(int x);
int main()
{
int num;
cout<<"Enter a number to calclate the table of the number and press Enter key: ";
cin>>num;
//Function call
table(num);
return 0;
}
//table function definition
void table(int x)
{
for(int a=1;a<=10;a++)
{
cout<<x<<" x "<<a<<" = "<<x*a<<endl;
}
}
Comments
Leave a comment