// this program will output a multiplication table for 1-5
#include <iostream>
usingnamespace std;
int main()
{
int table [4] [4];
int ans;
// creates the first colomn
for (int a; a<=4; a++)
{
table [a] [0] = a + 1;
}
// creates first row
for (int b; b<=4; b++)
{
table [0] [b] = b + 1;
}
// fills in the rest of the table
for (int c=1; c<=4; c++)
{
for (int d=1; d<=4; d++)
{
table [c][d] = (table [c][0]) * (table [0][d]);
}
}
// prints array
for (int i = 0; i <= 4; ++i)
{
for (int j = 0; j <=4; ++j)
{
cout << table[i][j] << "\n";
}
cout << endl;
}
}
When the variables in the example above are declared, they have an undetermined value until they are assigned a value for the first time. But it is possible for a variable to have a specific value from the moment it is declared. This is called the initialization of the variable.