### Problem with giving value to arrays

I want to make something will shows up like:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D

I am trying to use 2-D arrays.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455`` ``````#include using namespace std; void seat(char a[7][5]); int main() { char a[7][5]; seat(a); return 0; } void seat(char a[7][5]) { for(int i =0;i<7;i++) { for(int x =0;i<5;i++) { switch (x) { case 1: a[i][x] = 'A'; break; case 2: a[i][x] = 'B'; break; case 3: a[i][x] = 'C'; break; case 4: a[i][x] = 'D'; break; default: break; } } } for(int i =0;i<7;i++) { for(int x =0;i<5;i++) { cout << a[i][x] << " "; } cout << endl; } }``````

something weird just comes out, is it total wrong or just have some problem with the coding?
Line 46:
 `` `` `` for(int x = 0; i < 5; i++) //Change i's to x's ``

Edit:
Also, you never assigned a value when x = 0, so it still holds some junk value.
Last edited on
Thank you, fixed
Topic archived. No new replies allowed.