UP | HOME

HW27
COP-3223H

Create a random phrase generator using two arrays of strings and randomly combine them.

To create an array of strings, recall that strings are really just arrays of characters. Therefore an array of strings is a 2-dimensional array, e.g.,

char a1[2][32] = { "hello", "hi" };

Be sure that the second dimension, which is the size of the strings in the array, is larger than all strings in the array. Notice that instead of nested arrays, we have an array of string literals, which themselves are already arrays.

Create two of these arrays, e.g., a1 and a2, with at least 3 strings each. Then, using random number generation, create random two-word phrases. Recall that you can print strings using %s in printf, e.g.,

printf("%s %s", a1[2], a2[5]);

Make sure that every time the program runs, a different phrase is produced and that all possible combinations are strings are possible (no boundary condition errors).

Submit via git.

Author: Paul Gazzillo

Created: 2026-03-27 Fri 09:23

Validate