I created this code & it is producing the right output!. Can I use this instead of Prateek Bhaiya’s code?
#include
using namespace std;
int main()
{
char ch[20];
cin.getline(ch,20);
int j=0,i=j+1;
while(ch[j]!=’\0’){
if(ch[j]==ch[i])
i++;
else{
j++;
ch[j]=ch[i];
}
}
cout<<ch;
return 0;
}