can some one help, i am trying to print an array from a voidfunction, i can t se
ID: 3618030 • Letter: C
Question
can some one help, i am trying to print an array from a voidfunction, i can t seem to get the function to pass through, i keepgetting an error. i can print the array to the console but i wantto write a void function inorde to call upon it when i wan toprint. i am have problems passing the print function to my main andprinting it.here is my code below..please help:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int numberOfRow = 14;
const int numberOfCol = 7;
const int sentinal=-999;
void printseats(char Seats [][7],int row, char col);
int main ()
{
int seatRow;
char print;
string cusSeats [numberOfRow][numberOfCol]= {{" "," A"," B"," C"," D"," E"," F "},
{"Row 1"," * "," * "," * "," * "," *"," * "},
{"Row 2"," * "," * "," * "," * "," * "," * "},
{"Row 3"," * "," * "," * "," * "," * "," * "},
{"Row 4"," * "," * "," * "," * "," * "," * "},
{"Row 5"," * "," * "," * "," * "," * "," * "},
{"Row 6"," * "," * "," * "," * "," * "," * "},
{"Row 7"," * "," * "," * "," * "," * "," * "},
{"Row 8"," * "," * "," * "," * "," * "," * "},
{"Row 9"," * "," * "," * "," * "," * "," * "},
{"Row 10"," * "," * "," * "," * "," * "," * "},
{"Row 11"," * "," * "," * "," * "," * "," * "},
{"Row 12"," * "," * "," * "," * "," * "," * "},
{"Row 13"," * "," * "," * "," * "," * "," * "}};
// printto console works
//for (introw=0;row<numberOfRow; row++)
//{
// for (int col=0;col<numberOfCol; col++)
// cout<<setw(5)<<cusSeats[row][col];
//}
cout << "*****_AirLine Seats*****. ";
cout << "Please enter desired row. ";
cout << "To exit the program please enter -999. ";
cin >> seatRow;
while (seatRow != sentinal)
{
cout << "if you want to print the seating chart, press P or pfor printing. ";
cin >> print;
if (print=='P' &&print=='p')
cout<< printseats(Seats,numberOfRow,numberOfCol)<< endl;//iget the compiler error here
else
cout<< "you have entered an incorrect input.";
cout << "Please enter desired row. ";
cout << "To exit the program please enter -999. ";
}
return 0;
}
// print function
void printseats(string Seats [][7],int row, int col)
{
for (int row=0;row<14; row++)
{
for (int col=0;col<7; col++)
cout<< setw(5) <<Seats[row][col];
}
}
Explanation / Answer
please rate - thanks the function now prints see the red instructions #include #include #include #include #include using namespace std; const int numberOfRow = 14; const int numberOfCol = 7; const int sentinal=-999; void printseats(string Seats [][7],introw, int col); int main () { int seatRow; char print; string cusSeats [numberOfRow][numberOfCol]= {{" "," A"," B"," C"," D"," E"," F "}, {"Row 1"," * "," * "," * "," * "," * "," * "}, {"Row 2"," * "," * "," * "," * "," * "," * "}, {"Row 3"," * "," * "," * "," * "," * "," * "}, {"Row 4"," * "," * "," * "," * "," * "," * "}, {"Row 5"," * "," * "," * "," * "," * "," * "}, {"Row 6"," * "," * "," * "," * "," * "," * "}, {"Row 7"," * "," * "," * "," * "," * "," * "}, {"Row 8"," * "," * "," * "," * "," * "," * "}, {"Row 9"," * "," * "," * "," * "," * "," * "}, {"Row 10"," * "," * "," * "," * "," * "," * "}, {"Row 11"," * "," * "," * "," * "," * "," * "}, {"Row 12"," * "," * "," * "," * "," * "," * "}, {"Row 13"," * "," * "," * "," * "," * "," * "}}; // print to console works //for (int row=0;rowRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.