Kat H.

asked • 04/19/21

Cell Labeler. In a spreadsheet, the rows are numbered and the columns are lettered, like this:

In a spreadsheet, the rows are numbered and the columns are lettered, like this:


ABC
1 A1 B1 C1
2 A2 B2 C2


The code below reads in a number of rows and columns. Prints out the cells that would be in a grid of that size (do not worry about the column/row headers). For example something with 3 columns and 2 rows and should be displayed like:

A1 B1 C1
A2 B2 C2

You should print a space after every "cell", even the last one in each row. If spaces were changed to _ your output should look like:

A1_B1_C1_
A2_B2_C2_

Hint: Start by printing just the column and row as numbers:

11 21 31
12 22 32

Then you can worry about printing the column as a letter. Remember that to change a number into a letter you can add it to 'A' and store the result as a char.

char temp = x - 1 + 'A'; //temp will be 'A' if x is 1, 'B' if x is 2...


Code:


#include <iostream>

using namespace std;


int main()

{

int columns, rows;

cin >> columns >> rows;


//YOUR_CODE

}

1 Expert Answer

By:

Patrick B. answered • 04/20/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.