58.9k views
2 votes
Write a C++ code that will read a line of text and echo the line with all uppercase letters deleted. Assume the maximum length of the text is 80 characters. Example input/output is shown below.

Input:

Today is a great day!

Output:

oday is a great day!

1 Answer

6 votes

Answer:

#include<bits/stdc++.h>

using namespace std;

int main()

{

string st;

getline(cin,st);

int i=0;

while(i<st.length())

{

if(isupper(st[i]))

{

st.erase(st.begin()+i);

continue;

}

i++;

}

cout<<st<<endl;

return 0;

}

Step-by-step explanation:

I have included the file bits/stdc++.h which include almost most of the header files necessary.

For taking the input as a string line getline is used.

For checking the upper case isupper() function is used. cctype header file contains this function.

For deleting the character erase function is used.

User Raed Mughaus
by
5.5k points