Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the following program keeps crashing when I run it. When I ran thedebugger it sa

ID: 3610457 • Letter: T

Question

the following program keeps crashing when I run it. When I ran thedebugger it said I had an access Violation (segmentation fault) Ithink that is where it is trying to access parts of memory itshouldnt but I dont know where the problem in the code is or how tofix it. Any help is appreciated. Will Rate.

#include <iostream>
using namespace std;
int main()
{bool cards[4][13];
int hands[4][5][2];
string suit[4]={"hearts","diamonds","spades","clubs"};
stringcard[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
int i,j,num,type;
for(i=0;i<13;i++)
   for(j=0;j<13;j++)
      cards[i][j]=false;
for(i=0;i<4;i++)
    for(j=0;j<5;j++)
        {do
           {
           num=rand()%13;
           type=rand()%4;
           }while(cards[type][num]);
        hands[i][j][1]=type;
        hands[i][j][2]=num;
        cards[type][num]=true;
         }
for(i=0;i<4;i++)
   {cout<<"Hand "<<i+1<<": ";
       for(j=0;j<5;j++)
         cout<<card[hands[i][j][2]]<<" "<<suit[hands[i][j][1]]<<endl;
    cout<<endl;
    }
system("pause");
return 0;
}

Explanation / Answer

please rate - thanks the indices were 1 & 2 instead of 0 and 1 #include using namespace std; int main() {bool cards[4][13]; int hands[4][5][2]; string suit[4]={"hearts","diamonds","spades","clubs"}; stringcard[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"}; int i,j,num,type; for(i=0;i