You provided us a little information, I guess you are asking for a C++ code that first takes column number from user and then calculates rows on the basis of formula and finally creates a two dimensional array, right ?
Formula given : rows = 3columns.
I've written a C++ code for you
I've tested this code on my linux( ubuntu ) platform , I hope this is what you are asking.
#include <iostream>
#include<math.h>
#define kary 3 // Your k-ary truth table - 3 for ternary truth table(0,1,2), 2 for binary truth table(1,2)
using namespace std;
int main()
{
int rows,cols,i,j; // Variable declaration
cout<<"\n Enter required number of columns = ";
cin>>cols;
rows = pow(kary,cols);
cout<<"\n Calculated number of rows = "<<rows;
int arr[rows][cols]; // Array declaration
for (i=0; i<rows; i++)
{
for (j=0; j<cols; j++)
arr[i][j]=((i/(int) pow(kary, j)) % kary); //logic
}
cout<<"\n Your array holds this data \n";
for(i = 0; i < rows; i++)
{
for (j=cols-1; j>=0; j--)
cout<<"\t"<<arr[i][j];
cout<<"\n";
}
return 0;
}