when I run this sourcecode I have see errors so plz remove the errors if itpossi
ID: 3616027 • Letter: W
Question
when I run this sourcecode I have see errors so plz remove the errors if itpossible......
I want the output will be like this:
OUTPUT
enter a string:computer science
new string is : computer science
enter any letter: p
letter p = 4
source code
#include <iostream>
using namespace std;
int main()
{int i,j=0;
string s;
char newstring[100];
char last='1'; //set to anything butblank
cout<<"enter a string: ";
getline(cin,s);
for(i=0;s[i]!='';i++)
{
if(s[i]==' ')
{if(last!=' ')
newstring[j++]=s[i];
}
elseif(s[i]=='('&&s[i+2]==')')
{newstring[j++]=s[i+1];
i+=2;
}
else
newstring[j++]=s[i];
last=s[i];
}
newstring[j]=''; cout<<" original string:"<<s<<endl;
cout<<"enter any letter: "<<letter<<endl;
system("pause");
return 0;
}
Explanation / Answer
please rate - thanks #include using namespace std; int main() {int i,j=0; string s; char newstring[100],letter; char last='1'; //set to anything butblank coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.