Why it is not giving the same output

#include
using namespace std;
int main() {

int n,m,k,s;
cin>>m>>n>>k>>s;
char arr[1000][1000]={0};
for(int i=0;i<m;i++)

{
	for(int j=0;j<n;j++)
	{
		cin>>arr[i][j];
	}
}
bool success=true;


	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{char ch=arr[i][j];
			if(s<k)
			{
				success=false;
				break;
			}
			if(ch=='*')
				s=s+5;

			else if(ch=='.')
			s=s-2;
			
			else
				break;
			if(j!=n-1)
			s--;
		}
		
	}
if(success)
{
	cout<<"YES"<<endl;
	cout<<s;
}
else 
cout<<"NO";
return 0;

}

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
while(n!=0)
{
int number;
cin>>number;
int count=0;
int num=1;
while(count!=number)
{ for(int i=2;i<=sqrt(num);i++)
{
num++;
if(num%i==0)
break;
else
{
count++;
}

	}
}
	n--;
	
}
return 0;

}

Hi Megha. Kindly save ur code on ide and share that link

i didn’t get it, right now I am using Hackerblocks for this…


u can use it by going here.

let me see where are u going wrong

your code was perfectly fine. there was just one error. Instead of “Yes” u were printing “YES” and instead of “No” u were printing “NO”.

I have corrected ur code.


Hope ur doubt is cleared.
if ur doubt is resolved kindly mark the doubt as resolved and give ur valuable feedback

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.