Answer:
The answer to this question is "yes" and the program to this question can be given as:
Program:
#include <iostream> //include header file
using namespace std; //using namespace
class ab //define class
{
public: //access modifier
int i,tab; //defining variable.
void table(int n) //define method
{
for(i=1; i<=10; i++) //define loop.
{
tab=n*i; //calculate table.
cout<<tab<<endl; //print values.
}
}
};
int main() //define main method.
{
int n; //defining variable
cout<<"Enter any number :"; //message
cin>> n; //input number by user.
cout<<"Table of :" <<n<<endl; //message
ab ob; //creating class object.
ob.table(n); //calling function.
return 0;
}
Output:
Enter any number :2
Table of :2
2
4
6
8
10
12
14
16
18
20
Explanation: