online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** AUTHOR: MARIA LOGAN *******************************************************************************/ #include <iostream> using namespace std; void printSeatingChart(char seating_chart[13][6]); // <-- This tells C++ that a function named printSeatingChart // is going to be written later in the file. int main() { char seating_chart[13][6] { { 'X', '*', 'X', '*', '*', 'X' }, { '*', 'X', '*', '*', '*', 'X' }, { '*', '*', '*', '*', '*', '*' }, { '*', '*', 'X', '*', '*', 'X' }, { '*', '*', '*', '*', '*', '*' }, { 'X', '*', '*', '*', '*', 'X' }, { '*', '*', 'X', '*', '*', 'X' }, { 'X', '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*', '*' }, }; printSeatingChart(seating_chart); int ticket_type, desired_seat; cout << "Step 1) Prompt for the ticket type. " << endl; cout << "Please select the type of ticket you want to purchase: " << endl; cout << " 1) First Class " << endl; cout << " 2) Business Class" << endl; cout << " 3) Economy Class" << endl; cin >> ticket_type; cout << "Step 2) Prompt for the desired seat " << endl; cout << "*****Please use uppercase letters******" << endl; cout << "Please select your desired seat: " << endl; cout << " 1=A, 2=B 3=C 4=D 5=E 6=F " << endl; cin >> desired_seat; int j = desired_seat - 1; // calculate how far our desired seat is from the letter A. if(ticket_type == 1) // <-- Since ticket_type is now a character, it'll never be equal to the integer 1. { // It'll be equal to the character '1'. for(int i = 0; i <= 1; i++) { if(seating_chart[i][j] == '*') { seating_chart[i][j] = 'x'; break; } else { cout << "This seat is taken" << endl; } } } else if(ticket_type == 2) // <-- Since ticket_type is now a character, it'll never be equal to the integer 1. { // It'll be equal to the character '1'. for(int i = 0; i >= 2 && i <= 6; i++) { if(seating_chart[i][j] == '*') { seating_chart[i][j] = 'x'; break; } else { cout << "This seat is taken" << endl; } } } else if(ticket_type == 3) // <-- Since ticket_type is now a character, it'll never be equal to the integer 1. { // It'll be equal to the character '1'. for(int i = 0; i >= 7 && i <= 12; i++) { if(seating_chart[i][j] == '*') { seating_chart[i][j] = 'x'; break; } else { cout << "This is seat is taken" << endl; } } } else { cout << "please enter a valid selection" << endl; } printSeatingChart(seating_chart); } void printSeatingChart(char seating_chart[13][6]) { cout << "\tA B C D E F" << endl; // For every row in our seating chart for(int i = 0; i < 13; i++) { // Print the row number. cout << "Row " << (i+1) << " "; // For every seat on the current row. for(int j = 0; j < 6; j++) { // Print the current seat. cout << seating_chart[i][j] << " "; // Individual seats } // Print the end of the line, so the next row will be printed on a new line. cout << endl; // Going to the next row } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue