1.

Define a function to input a list of names and store them as dynamically-allocated strings in an array, and a function to output them:

  • void ReadNames (char *names[], const int size);
  • void WriteNames (char *names[], const int size);

Write another function which sorts the list using bubble sort:

void BubbleSort (char *names[], const int size);

Bubble sort involves repeated scans of the list, where during each scan adjacent items are compared and swapped if out of order. A scan which involves no swapping indicates that the list is sorted.

2.

Write a program to add two fractions and display the result fraction. Your program will prompt the user to input fraction 1 and fraction 2. The numerator and denominator of each fraction are input separately by space.  See the sample output below. You will need to use a C++ structure to define a fraction. The structure has two members: numerator and denominator.

Example:
Fraction 1 Numerator - 5
Fraction 1 Denomenator - 6

Fraction 1 Numerator - 3
Fraction 1 Denomenator - 6

Output : - 4/3

3.

Write a program that reads values for the length and width of a rectangle and displays the perimeter and area of the rectangle.

A sample output is shown below:
 

Length = 25

Width = 14

Perimeter is 78

Area is 350