(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...

Bulleted lists in Word are generally used when there is a particular order to the items in a list

Indicate whether the statement is true or false

Computer Science & Information Technology

Which of the following statements is false?

a. JavaFX Scene Builder is a standalone JavaFX GUI visual layout tool that can also be used with various IDEs. b. JavaFX Scene Builder enables you to create GUIs by dragging and dropping GUI components from Scene Builder’s library onto a design area, then modifying and styling the GUI—all without writing any code. c. The FXML code is integrated with the program logic that’s defined in Java source code—this integration of the interface (the GUI) with the implementation (the Java code) makes it easier to debug, modify and maintain JavaFX GUI apps. d. JavaFX Scene Builder generates FXML (FX Markup Language)—an XML vocabulary for defining and arranging JavaFX GUI controls without writing any Java code.

Computer Science & Information Technology

A table organizes data in vertical rows._________________________

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

Computer Science & Information Technology

With an omnidirectional antenna, the radio wave flows outward from the wireless access point (WAP) in one direction.

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

Computer Science & Information Technology