C++ PROGRAM TO REMOVE CHARACTERS EXCEPT ALPHABETS IN A STRING
Sample Test Case : Enter the String : 3He*ll#o!
Sample Output : Hello
CODE
#include<bits/stdc++.h>
using namespace std;
int main()
{
string line;
cout<<"Enter a String : ";
getline(cin,line);
for(int i=0;i<line.size();++i)
{
if(!((line[i]>='a'&& line[i]<='z')||(line[i]>='A'&&line[i]<='Z')))
{
line[i]='\0';
}
}
cout<<"Output String :"<<line;
return 0;
}

No comments:
Post a Comment