Print tables using function in C++


Example Program:

Here is the simple program for printing tables using function in C++.

Source Code Example : 1

#include<iostream>
using namespace std;
void tables();
int main()
{
    tables();
    return 0;
}
void tables()
{
    int i,j,n;
    cout<<"\nEnter the Table number:";
    cin>>j;
    cout<<"\nEnter the limit:";
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cout<<"\n"<<i<<"*"<<j<<"="<<i*j;
    }
}
To download raw file Click Here

Output

Enter the Table number:10
Enter the limit:10
1*10=10
2*10=20
3*10=30
4*10=40
5*10=50
6*10=60
7*10=70
8*10=80
9*10=90
10*10=100

Source Code Example : 2

#include<iostream>
using namespace std;
void tables(int,int);
int main()
{
    int i,j,n;
    cout<<"\nEnter the Table number:";
    cin>>j;
    cout<<"\nEnter the limit:";
    cin>>n;
    tables(j,n);
    return 0;
}
void tables(int j,int n)
{
    int i;
    for(i=1;i<=n;i++)
    {
        cout<<"\n"<<i<<"*"<<j<<"="<<i*j;
    }
}
To download raw file Click Here

Output

Enter the Table number:10
Enter the limit:10
1*10=10
2*10=20
3*10=30
4*10=40
5*10=50
6*10=60
7*10=70
8*10=80
9*10=90
10*10=100

Source Code Example : 3

#include<iostream>
using namespace std;
void tables();
int main()
{
    tables();
    return 0;
}
void tables()
{
    int i,j,n;
    cout<<"\nEnter the Table number:";
    cin>>j;
    cout<<"\nEnter the limit:";
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cout<<"\n"<<i<<"*"<<j<<"="<<i*j;
    }
}
To download raw file Click Here

Output

Enter the Table number:10
Enter the limit:10
1*10=10
2*10=20
3*10=30
4*10=40
5*10=50
6*10=60
7*10=70
8*10=80
9*10=90
10*10=100

Basic Programs


Flow Control

IF Statement Examples


Switch Case

Goto Statement

Break and Continue

While Loop

Do While Loop

For Loop

Friend Function in C++


String Examples


Array Examples


Structure Examples


Structure & Pointer Examples


Structure & Functions Examples


Enumeration Examples


Template Examples


Functions


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples



Learn All in Tamil © Designed & Developed By Tutor Joes