Hi Only 2 cases are passing. Can you please tell me what exactly is wrong?

#include <stdio.h>
#include
#include
#include
using namespace std;
int main() {

int n;//rows
int m;//column
int k;//needed
int s;//strength
cin >> n >> m >> k >> s;
char ar[n][m];
for (int i = 0; i < n; i++)
{
	for (int j = 0; j < m; j++)
	{
		cin >> ar[i][j];
	}
}
int flag = 0;
for (int i = 0; i < n; i++)
{

	for (int j = 0; j < m; j++)
	{
		if (s < k)
		{
			flag = 1;
			break;
		}
		else if (ar[i][j] == '.')
			s = s - 2;
		else if (ar[i][j] == '*')
			s = s + 5;
		else if (ar[i][j] == '#')
			break;
		if (j != m - 1)
			s--;
	}
}
if (flag == 0)
	cout << "Yes";
else
	cout << "No";
cout << endl << s;
return 0;

}

Hello @suhaib0900 i have corrected and commented the mistake in your code:

Okay Got it. Thanks! You can close the thread.

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.