(Strings Ending with ED) Write a program that reads a series of strings and prints only those strings that end with the letters “ED.”
What will be an ideal response?
```
#include
#include
using namespace std;
const int SIZE = 20;
int main()
{
int length, i;
char array[ 5 ][ SIZE ];
// take five strings and store into character array
for ( i = 0; i <= 4; i++ )
{
cout << "Enter a string: ";
cin.getline( &array[ i ][ 0 ], SIZE );
} // end for
cout << "\nThe strings ending with \"ED\" are:\n";
// review each string
for ( i = 0; i <= 4; i++ )
{
length = strlen( &array[ i ][ 0 ] );
// check if string ends with "ED"
if ( strcmp( &array[ i ][ length - 2 ], "ED" ) == 0 )
cout << &array[ i ][ 0 ] << '\n';
} // end for
return 0;
} // end main
```
Enter a string: MOVED
Enter a string: SAW
Enter a string: RAN
Enter a string: CARVED
Enter a string: PROVED
The strings ending with "ED" are:
MOVED
CARVED
PROVED
You might also like to view...
Which openSUSE administrator tool enables administrators to install and manage software?
A. YaST B. Setup C. Ysetup D. SetMan
A class ____ consists of the operations permitted to be performed on an object's data members.
A. instantiation B. environment C. behavior D. state
What is the very first step that should be taken when performing work with a computer?
A. You should back up any important data. B. You should ground yourself. C. You should remove the power supply. D. You should power down the system and unplug it.
You tasked with finding and labeling where a network connection terminates in a patch panel. Which of the following tools would be BEST for you to use?
A. Ethernet cable tester B. Tone generator and probe C. RJ-45 loopback plug D. Patch panel punchdown tool