(Strings Beginning with b) Write a program that reads a series of strings and prints only those strings beginning with the letter “b.”

What will be an ideal response?

```
#include
using namespace std;

const int SIZE = 20;

int main()
{
char array[ 5 ][ SIZE ];
int i;

// take in five strings
for ( i = 0; i <= 4; i++ )
{
cout << "Enter a string: ";
cin.getline( &array[ i ][ 0 ], SIZE );
} // end for

cout << "\nThe strings starting with 'b' are:\n";

// run through the array and see if any string started with 'b'
for ( i = 0; i <= 4; i++ )

if ( array[ i ][ 0 ] == 'b' )
cout << &array[ i ][ 0 ] << '\n'; // print out the string

return 0;
} // end main
```
Enter a string: apples
Enter a string: bananas
Enter a string: blueberries
Enter a string: tomatoes
Enter a string: bread
The strings starting with 'b' are:
bananas
blueberries
bread

Computer Science & Information Technology

You might also like to view...

To test a hyperlink, you first select the name of the hyperlink on the Hyperlinks panel, then click the right arrow button, called the Go to destination of the selected hyperlink or cross-reference button.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Encryption is the method in which data are protected during a transaction._________________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology