Yes, this is a homework assignment, however once again I am just trying to spruce it up some with the x values being displayed (not required for the homework). It would be better if I could get the y values to display as well but I can't seem to get that to happen. I have tried putting in several differentfor iterations as well as if/else only to not get what I was looking for. Any help would be appreciated. Again, by taking out the x values being displayed I will get full credit, so I have the assignment done. Thanks in advance.
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
usingnamespace std;
int main()
{
cout << endl << "ASCII Spreadsheet " << endl << endl;
int x, y;
for (x = 40; x < 120; x += 10)
{
cout << setw(4) << x;
for (y = 0; y < 10; y++)
{
cout << setw(4) << char(x+y);
}
cout << endl;
}
return 0;
}
The following is the output:
ASCII Spreadsheet
40 ( ) * + , - . / 0 1
50 2 3 4 5 6 7 8 9 : ;
60 < = > ? @ A B C D E
70 F G H I J K L M N O
80 P Q R S T U V W X Y
90 Z [ \ ] ^ _ ` a b c
100 d e f g h i j k l m
110 n o p q r s t u v w
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
usingnamespace std;
int main()
{
cout << endl << "ASCII Spreadsheet " << endl << endl;
int x, y;
for (y = 0; y < 10; y++)
{
cout << setw(4) << y << "\t";
cout << endl;
}
for (x = 40; x < 120; x += 10)
{
cout << setw(4) << x;
for (y = 0; y < 10; y++)
{
cout << setw(4) << char(x+y);
}
cout << endl;
}
return 0;
}
However the output was as follows:
ASCII Spreadsheet
0
1
2
3
4
5
6
7
8
9
40 ( ) * + , - . / 0 1
50 2 3 4 5 6 7 8 9 : ;
60 < = > ? @ A B C D E
70 F G H I J K L M N O
80 P Q R S T U V W X Y
90 Z [ \ ] ^ _ ` a b c
100 d e f g h i j k l m
110 n o p q r s t u v w
Obviously I have missed a step. I tried variations of where to put a tab in, trying to get them all on the same line (even white space cout << " ";) but the end result is typically identical to what is shown above.
That worked and has gotten me on the right track. Thanks. Being a beginner at this stuff, sometimes it makes me laugh how a simple error like that can change everything. Thanks again for the help.