4
Using Multidimensional Array in C++
The table below are the first names of people who went for check up at the bisi maternity home and were attended to by 3 doctors in 2 rooms. Using multidimensional array, write a C++ program that displays thus:
Name of Patient: Doctor that treated her - Room where she was treated.
Doctor/Room | Doctor 1 | Doctor 2 | Doctor 3 |
Room 1 | Afueh | Arabia | Johnson |
Room 2 | Benjamin | Koronil | Chelses |
Solution:
#include
using namespace std;
int main(){
string med[4][3] = {
{"Doctor 1","Doctor 2","Doctor 3"},
{"Afueh","Arabia","Johason"},
{"Benjamin","Koromp","Chelses"},
{"","Room 1","Room 2"}
};
for(int x=0;x<3;x++){
for(int y=1;y<3;y++){
cout <<med[y][x]<<": "<<med[0][x] << " - " <<med[3][y]<<endl;
}
}
return 0;
}