Site hosted by Angelfire.com: Build your free website today!

Program #23 

 

 


This program will use three 2-dimensional arrays. Arrays of names. ( arrays of characters.)

 

The first will hold 5 people’s first names and the second will hold 5 last names.  The third will hold 5 middle names.

            char first[5][20], middle[5][20];

Call a function that will have the five first and five last names entered.

            Getnam(nam);

 

            Inside the function you will have a loop like this…

                        for(x=0; x<5; ++x)

                        { cin.get(first[x], 20);

                                    cin.ignore(20, ‘\n’);

                                    cin.get(last[x], 20);

                                      cin.ignore(20, ‘\n’);

                        }

 

Call another function that will have five middle names entered.

            Getmid(middle);

Call a third function that will create the complete name with the first, middle, and last.

            Create(first, last, middle);

Call a fourth that will PRINT this new name, still called first.

            Print(first);

 

            Hint: There is a BUILT IN function that will concatenate strings.

            The name of this function is strcat.

            It is in the string.h library.

Use it like this…

            strcat(first[x], “ “);

            strcat(first[x], middle[x]); and add another space and then last

OUTPUT

1)      Puff Oscar Daddy

2)      Britney Sophie Spears

3)      Bjarne Tex Stroustrup

4)      Bobby C++ Borland

5)      Bill Apple Gates