Generate Table In C++ with N lenght

Tables are a really basic part of mathematics.  From a very beginning, children are taught tables because of their integral part in future studies. Have you ever wanted to have a program that could give you a table of any number you want up till how much you want it. Well in the following program we will discuss the code for M * N table generation, where M and N can be any integer number.

The first part involves declaring the necessary header files.

#include <iostream>
#include <conio.h>
using namespace std;
void main()
{

we will initialize two integers that will be the M and N part of our program and get the required numbers from the user in them using cin command.

int a;
int b;
cout<<"enter the number you want the table of:";
cin>>a;
cout<<"enter till how long you want the table to be:";
cin>>b;

for the main logic, We use a for loop up till N times, and we will multiply M with the loop integer thus getting the table we desire.

     for (int i=0;i<=b;i++)
    {
      cout<<a;cout<<" * ";
      cout<<i;
      cout<<"=";
      cout<<a*i;
      cout<<"n";
      getch();
     }
}

This program will give you the table that is entered by the user in the console menu.

Let's Discuss

  • http://www.thisandthatcleaningservices.com/residential.html cleaning services nj

    Reading this article really made me think. This is good quality information that anyone should be able to understand and use. Your ideas are valid and I agree with you.