Wrong answer even on sample case

#include<bits/stdc++.h>
using namespace std;
int main() {
string s; cin >> s; int n = s.length();
for(int i = 0; i < n; i++){
if(s[i] >= ā€˜A’ && s[i] <= ā€˜Z’){
cout<< endl << s[i];
}
cout<<s[i];
}
}

Hi, the problem is that you are printing the Capital letters twice. Please put print statement after if block inside a else block.

1 Like