Question

In: Computer Science

Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E.

4.8.2: Nested loops: Print seats. C++

Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numColumns = 3 prints:

1A 1B 1C 2A 2B 2C

#include
using namespace std;

int main() {
int numRows;
int numColumns;
int currentRow;
int currentColumn;
char currentColumnLetter;

cin >> numRows;
cin >> numColumns;

/* Your solution goes here */

cout << endl;

return 0;
}

Solutions

Expert Solution

#include 

using namespace std;

int main()
{
   int numRows;
    int numColumns;
    int currentRow;
    int currentColumn;
    char currentColumnLetter;

   cin>>numRows;
   cin>>numColumns;
   
   // Looping from 1 to numRows
    for(currentRow=1;currentRow<=numRows;currentRow++){
      currentColumnLetter = 'A';
      // Looping from 0 to numColumns
      for(currentColumn=0;currentColumn
                    

Related Solutions

Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered,...
Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Use separate print statements to print the row and column. Ex: numRows = 2 and numColumns = 3 prints: 1A 1B 1C 2A 2B 2C import java.util.Scanner; public class NestedLoops {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);      ...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered,...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numCols = 3 prints: 1A 1B 1C 2A 2B 2C #include <iostream> using namespace std; int main() {    int numRows = 2;    int numCols = 3;    // Note: You'll need to define more variables    /* Your solution goes...
Given numRows and numCols, print a list of all seats in atheater. Rows are numbered,...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numCols = 3 prints:1A 1B 1C 2A 2B 2C#includeint main(void) {int numRows = 2;int numCols = 3;// Note: You'll need to declare more variables/* Your solution goes here */printf("\n");return 0;}
in java Print a list of seats in a theater. Rows are numbered, columns lettered, as...
in java Print a list of seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat. Create a nested loop to print the following: 1A 1B 1C 1D 3A 3B 3C 3D 5A 5B 5C 5D
SOLVE IN C: Given numRows and numColumns, print a list of allseats in a theater....
SOLVE IN C: Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numColumns = 3 prints:1A 1B 1C 2A 2B 2C
A Theater has n numbered seats, and n tickets are distributed among n persons. Compute the...
A Theater has n numbered seats, and n tickets are distributed among n persons. Compute the probability that (a) exactly two persons will be seated at seats corresponding to their ticket numbers if all the seats are occupied at random. (b) at least two persons will be seated at seats corresponding to their ticket numbers if all the seats are occupied at random.
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given).
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given). Important: Next, the expression "a single line of code" implies a single command or equality. In other words, the code: X=A+1; X=X+B; is considered to be TWO lines of code, even though it can be written as one line. (a) (3%) Write a single line of code which saves the first two rows of array A...
Write a Python program which adds up columns and rows of given table as shown in...
Write a Python program which adds up columns and rows of given table as shown in the specified figure. Example test case (the four lines below “Input cell value” are input from user, and the five lines below “Results:” are the output of the program.): Input number of rows/columns (0 to exit) 4 Input cell value: 25 69 51 26 68 35 29 54 54 57 45 63 61 68 47 59 Result:             25   69   51   26 171...
Write a Python program which adds up columns and rows of given table as shown in...
Write a Python program which adds up columns and rows of given table as shown in the specified figure. Example test case (the four lines below “Input cell value” are input from user, and the five lines below “Results:” are the output of the program.): Input number of rows/columns (0 to exit) 4 Input cell value: 25 69 51 26 68 35 29 54 54 57 45 63 61 68 47 59 Result: 25 69 51 26 171 68 35...
MATLAB Create a matrix named P which has 2000 rows and 100 columns of all zeros....
MATLAB Create a matrix named P which has 2000 rows and 100 columns of all zeros. Replace the zeros in rows 46-58 and columns 3-18 of matrix P from the previous question with ones.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT