Regarding this program


sir I am getting a wrong output can you please check

for(int i=0;i<str.length()-1;i++){
this is wrong you have to go till end
so condition should be i<str.length() or i<=str.length()-1