One Test Case showing wrong

#include
#include
using namespace std;

void Readability(string S)
{
int i=0;
int j;
j=i+1;
while(j<S.length() && i<S.length())
{
while(S[j]>=97 && S[j]<=122 && j<S.length())
j++;

        for(;i<=j-1;i++)
            cout<<S[i];
            cout<<endl;
        i=j;
        j++;
}

}

int main()
{
string S;
getline(cin,S);
Readability(S);
}

hi @Mukul-Shane-1247687648773500
ur code is failing on two type of test case…

  1. if string contains only one capital letter
  2. if string contains consecutive capital letters … for example string is AAA
    ur o/p -->
A
A

expected o/p -->

A
A
A

refer this code -->

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.