| CMPSC 101 - Variables Worksheet #10 | Name - |
1. In the right margin, show what output would be displayed by the following program.
#include <iostream>
using namespace std;int main()
{
int row = 0;
int column = 0;
int numIterations = 0;
for (row = 1; row <= 3; row++)
{
for (column = 1; column < 5; column++)
{
cout << row << "-" << column << " ";
numIterations++;
}
cout << endl;
}
cout << numIterations << endl;
return 0;
}
2. In the right margin, show what output would be displayed by the following program.
#include <iostream>
using namespace std;int main( )
{
int number = 10;
int sum = 0;
while (number > 0)
{
sum = sum + number;
number--;
cout << sum << endl;
}
return 0;
}