Hey there, everyone.
Here is the question I had to write code for:
Include the following code:
char test[15] = {‘T’, ‘h’, ‘i’,’s’, ‘_’, ’i’, ’s’, ‘_’, ’a’, ‘_’, ’t’, ’e’, ’s’, ’t’};
for (int row = 0; row < 15; row++)
{ cout << test[row]; }
Add the code within the for loop to display only the characters t, e, and s using if/else or case statements.
Here is what I turned in:
#include <iostream>
using namespace std;
void main()
{
char test[15] = {'T', 'h', 'i','s', '_', 'i', 's', '_', 'a', '_', 't', 'e', 's', 't'};
int row;
cout << "Characters 10-12 are:"<<endl;
for (char row = 0; row <15; row++)
{
if(row > 9)
if (row < 13)
{ cout << test[row]; }
else;
}
cout << "\n" <<endl;
}
I thought this was good. But it was handed back to me to redo. My teacher said he wants to see me do this using the exact character letter. I guess meaning by doing 't' 'e' 's'. I am confused as to how to re-write the code this way. Any help is appreciated. Thanks!