on Leave a Comment

C++ Program to Print Multiplication Table

C++ Program to Print Multiplication Table

#include<iostream>
using namespace std;
int main()
{
    int n;
    cout<<"Enter a positive number : ";
    cin>>n;
    cout<<endl<<"Multiplication Table of "<<n<<" is "<<endl;
    for(int i=1;i<=10;i++)
    {
        cout<<endl;
        cout<<n<<" x "<<i<<" = "<<n*i;
    }
    return 0;
}

OUTPUT: 

Enter a positive number : 6

Multiplication Table of 6 is

6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60

C++ program to print multiplication table up to a given range

#include<iostream>
using namespace std;
int main()
{
    int n;
    cout<<"Enter a positive number : ";
    cin>>n;
    cout<<"Enter range : ";
    int r;
    cin>>r;
    cout<<endl<<"Multiplication Table of "<<n<<" is "<<endl;
    for(int i=1;i<=r;i++)
    {
        cout<<endl;
        cout<<n<<" x "<<i<<" = "<<n*i;
    }
    return 0;

}

OUTPUT:

Enter a positive number : 6
Enter range : 15

Multiplication Table of 6 is

6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60
6 x 11 = 66
6 x 12 = 72
6 x 13 = 78
6 x 14 = 84
6 x 15 = 90

0 comments:

Post a Comment