In output strength value is not changed < Piyush & Magical Park >

#include
using namespace std;

void MagicalPark(char Array[][100],int m,int n, int minStrength, int PlayerStrength)
{
bool success=true;

for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (PlayerStrength<minStrength)
{
success=false;
break;
}

        if (Array[i][j]=='.')
        {
            PlayerStrength-=2;
        }
        if (Array[i][j]=='*')
        {
            PlayerStrength+=5;
        }
        else
        {
            break;
        }

        if (j!=n-1)
        {
            PlayerStrength--;
        }   
    }
}

if (success)
{
    cout<<"Yes"<<endl;
    cout<<PlayerStrength<<endl;
}
else
{
    cout<<"no"<<endl;
}

}

int main()
{
int m,n;
cin>>m>>n;
int minStrength,PlayerStrength;
cin>>minStrength>>PlayerStrength;
char Array[100][100];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cin>>Array[i][j];
}
}

MagicalPark(Array,m,n,minStrength,PlayerStrength);
return 0;   

}

Hello @rprahulpal03 please wait i am checking your code:

@rprahulpal03 i have corrected your code:
you shoudl use else if instead of if while checking:


if you have any doubt you can ask here:
Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.