I am trying to figure out how to do this : Write a program that displays a table
ID: 3621275 • Letter: I
Question
I am trying to figure out how to do this :
Write a program that displays a table resembling a spreadshet.The column headings should show the values A,B,C,D, and E, and the row headings should show 1,2,3,4,and 5. The row values should be multiples of the value of the row number.Use a for loop to output the column headings. Use nested for loops to output the row number and the values within the rows and columns. The output should look like the following:
A B C D E
1 1 2 3 4 5
Please I do not know how to do this question....ugggh very frustrated.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int i=0,j=0,cols=5,k,digits=4,row,rows=5;
digits=4;
for (i =1;i<digits;i++)
cout<<" ";
for (i =0;i<cols;i++)
cout<<setw(4)<<(char)('A'+i);
cout<<" ";
for (row=1;row<=rows;row++)
{cout<<row<<" ";
{for(j=1;j<=cols;j++)
cout<<setw(4)<<row*j;
cout<<endl;
}
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.