Why is that in my out it's not changing the line

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

string s;
cin >> s;
string str = "";
int l = s.length();
for (int i = 0; i < l; i++)
{
	char ch = s[i];
	if (ch >= 'A' && ch <= 'Z')
	{
		cout << ch;
	}
	else if (ch >= 'a' && ch <= 'z')
	{
		cout << ch;
	}
	else if (ch >= 'A' && ch <= 'Z')
	{
		cout << endl;
		cout << ch;
	}
}
return 0;

}

Hello @suhaib0900 please wait i am checking your code.

check this :


i have corrected and commented the mistake:
Happy Learning!!

@suhaib0900 i have commented the mistake in the correct code which i have given to you.

Yeah sorry about that I checked in the wrong place. Thanks a lot.

have you understood the mistake?

Yeah I did. Basically the first if will only run if the first element of the string is Capital right?

@suhaib0900 yes right.

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.