• Register
Log In

We can use a program for creating tables in an app related to databases or spreadsheets. So now we understand the need for tables in software. In this article, we are going to learn how to create a table in C++? And creating tables in C++ is pretty easy.



Rows and columns together form a table. How is that line beneficial for you? It is beneficial since it tells you the variables you need to create or initialize in your program. We will need two variables in this program 1. Rows and 2. Columns 

Since each row consists of a number of columns or you can say each column consists of a number of rows.  For an easy understanding of the program, we will be talking about only one case. It means I’ll be talking about each row consisting of a number of columns.

It is clear by definition that we have to add columns inside the rows and for doing that we will be using nested for loops. 

Nested for loop

Nested for loop means loop inside a loop.



#include <iostream>
using namespace std;
int main()
    int rows,columns;

    for (rows = 1; rows <= 6; rows++)
        for (columns = 1; columns <= 6; columns++)
            cout << columns;
        cout << "\n";
    return 0;


posted Jun 1 in c++ 100 points