Hi guys! I am new using c++ and I want to ask you; How can I break this loop I made if the values I am using are stored in arrays. Also, is the while loop the best one to use? Thank you! :D
1 2 3 4 5 6 7 8 9 10 11 12 13
while(score[1][5] = score[2][10])
{
cout<<"xxxx Enter the score in overtime by Team 1:"<<endl;
cin>>score[1][1];
cout<<"xxxx Enter the score in overtime by Team 2:"<<endl;
cin>>score[2][6];
if(score[1][1] > score[2][6])
cout<<"xxxx The Winner is Team 1";
elseif(score[1][1] < score[2][6])
cout<<"xxxx The Winner is Team 2";
}
int main()
{
int score[2][5] = {{0,0,0,0,0} , {0,0,0,0,0}};
cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxxxxxxxxxxxxxxx NBA 2k15 xxxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxxxxxxxxxxxxxxx Score box xxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxx Enter the score in the first quarter by Team 1:"<<endl;
cin>>score[1][1];
cout<<"xxxx Enter the score in the second quarter by Team 1:"<<endl;
cin>>score[1][2];
cout<<"xxxx Enter the score in the first quarter by Team 1:"<<endl;
cin>>score[1][2];
cout<<"xxxx Enter the score in the first quarter by Team 1:"<<endl;
cin>>score[1][3];
cout<<"xxxx Enter the score of the first quarter by Team 2:"<<endl;
cin>>score[2][6];
cout<<"xxxx Enter the score of the second quarter by Team 2:"<<endl;
cin>>score[2][7];
cout<<"xxxx Enter the score of the third quarter by Team 2:"<<endl;
cin>>score[2][8];
cout<<"xxxx Enter the score of the fourth quarter by Team 2:"<<endl;
cin>>score[2][9];
score[1][5]= score[1][1]+score[1][2]+score[1][3]+score[1][4];
score[2][10]= score[2][6]+score[2][7]+score[2][8]+score[2][9];
cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxxxxxxxxxxxxxxx NBA 2k15 xxxxxxxxxxxxxxxxxxxx"<<endl;
cout<<"xxxxxxxxxxxxxxxxx Score box xxxxxxxxxxxxxxxxxxx"<<endl;
do
{
cout<<"xxxx Enter the score in overtime by Team 1:"<<endl;
cin>>score[1][1];
cout<<"xxxx Enter the score in overtime by Team 2:"<<endl;
cin>>score[2][6];
if(score[1][5] = score[2][6])
{
if(score[1][1] > score[2][6])
cout<<"xxxx The Winner is Team 1";
else if(score[1][1] < score[2][6])
cout<<"xxxx The Winner is Team 2";
will always be true.
Perhaps you meant to use equality test (==) instead of assignment (=) if(score[1][5] == score[2][6])
Can't give line numbers because you didn't format (or indent) your code :-(