I have given the link, please check

the code can be opened from the link.

Consider the input AAAA
Ur o/p - A
Expected o/p -->

A
A
A
A

Try to correct it…

#include <iostream>
using namespace std;
int main() {
    string s;
    cin>>s;
    string temp;
    int n = s.size();
    for(int i=0;i<n;i++){
        temp += s[i];
        if(i == n-1){ //last letter
            cout<<temp;
        }
        else if(s[i+1] >= 'A' && s[i+1] <= 'Z'){  //s[i+1] is a capital letter(ie next letter is capital)
            cout<<temp<<endl;
            temp.erase();
        }
    }
}

refer this code if u still face any difficulty…

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.