Find the output of the following program.... and please explain the output..........
int main()
{
randomize();
int NUM;
NUM = random(3) + 2;
char TEXT[] = "ABCDEFGHIJK";
for (int I = 1; I <= NUM; I++)
{
for (int J = NUM; J <= 7; J++)
cout << TEXT[J];
cout << end1;
}
}
1
Expert's answer
2016-01-19T08:28:41-0500
Function randomize() reset generator of random numbers. So, since random create number from 0 to 2, NUM can be from 2 to 4. In the next line we start cycle from 1 to NUM, in which we output symbols from NUM to 7 (so, we output 7-NUM+1 characters, which start from C (or D or E) and continues to H. So, we have from 2 to 4 lines, each line contain symbols from C(or D or E) to H, and this lines a same For example, it can be: EFGH EFGH EFGH EFGH
Comments