Question

In: Computer Science

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


Solutions

Expert Solution

#include 

int main() {
   int numRows;
   int numColumns;
   int currentRow;
   int currentColumn;
   char currentColumnLetter;
   
   // Read number of rows
   scanf("%d", &numRows);
   
   // Read number of columns
   scanf("%d", &numColumns);
   
   // Value of currentRow running from 1 to numRows
   for(currentRow=1; currentRow<= numRows; currentRow++)
   {
      // Value of currentColumn running from ascii value from A
      for(currentColumn=65; currentColumn <= 65 + numColumns -1; currentColumn++)
      {
         // Converting integer currentColumn to char
         currentColumnLetter = currentColumn;
         // Printing Value of currentRow and currentColumnLetter
         printf("%d%c ",currentRow,currentColumnLetter);
      }
   }
   
   // Printing new line at the end
   printf("\n");
   
   return 0;
}

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 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#includeusing 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;}
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
I am having a difficult time with this loop. Needs to be in C++. Given numRows...
I am having a difficult time with this loop. Needs to be 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 #include <iostream> using namespace std; int main() { int numRows; int numColumns; int currentRow; int currentColumn; char currentColumnLetter;...
(C++) Write a program that reads a list of integers from the keyboard and print out...
(C++) Write a program that reads a list of integers from the keyboard and print out the smallest number entered. For example, if user enters 0 3 -2 5 8 1, it should print out -2. The reading stops when 999 is entered.
Please use C++ and linked list to solve this problem Linked list 1 -> 3 ->...
Please use C++ and linked list to solve this problem Linked list 1 -> 3 -> 4 -> 5-> 6 ->7 replaceNode( 5 , 6) // Replace 5 with 6     result 1 -> 3 -> 4 -> 6 -> 6 ->7 Base code #include <iostream> using namespace std; class Node { public:     int data;     Node *next;     Node(int da = 0, Node *p = NULL) {         this->data = da;         this->next = p;     } };...
Please use C++ and linked list to solve this problem Linked list 1 -> 2 ->...
Please use C++ and linked list to solve this problem Linked list 1 -> 2 -> 3 -> 4 -> 5-> 6 ->7 replaceNode( 5 , 6) // Replace 5 with 6     result 1 -> 2 -> 3 -> 4 -> 6 -> 6 ->7 Base code #include <iostream> using namespace std; class Node { public:     int data;     Node *next;     Node(int da = 0, Node *p = NULL) {         this->data = da;         this->next =...
(C++) Follow the template given to calculate and print the monthly salary of an employee. We...
(C++) Follow the template given to calculate and print the monthly salary of an employee. We assume the employee works for 50 weeks during the year with an hourly rate of $25. Your program should ask the user the workHoursPerWeek. If it's over 40, then the excess hours (i.e., workHoursPerWeek over 40) are paid with 20% overtime rate. Note: just print out the monthly salary. Example: If I work for 45 hours with a rate of $30/hr, then my weekly...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT