Sunday 19 July 2020

Table of Any Number Program in C++

Table of any Number Program in C++ 

This code is very simple and easy to write Table of any number program in C++



#include <iostream>
using namespace std;
int main() {
    int n, term, i;     
    cout << "Enter a number to print table\n";
    cin >> n;
    cout << "Enter the number of terms in table\n";
    cin >> term;
    for(i = 1; i <= term; ++i){
        cout << n << " X " << i << " = " << n*i << endl;
    }      
    return 0;
}



  Output



Enter a number to print table
5
Enter the number of terms in table
10
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50



No comments:

Post a Comment