Answer:
Following are the code to this question:
#include<iostream>//declaring header file
using namespace std;
void decode(string* arr, int n)//defining a method decode
{
for(int i = 0; i < n; i++)//defining a loop for print value
{
cout << arr[i][i] << " "; // using print method to print ith letter of the string
}
cout << endl;//line break
}
int main()//defining main method
{
string secret1[] = {"platypus","plethora","trend","croak","almost","toaster"};//defining string arry and assign value
string secret2[] = {"fire","seen","trend","produce"};//defining string arry and assign value
string secret3[] = {"tiretread","chains","stern","bed bug"};//defining string arry and assign value
string secret4[] = {"oracle","stetson","mother","stie","twigrot"};//defining string arry and assign value
decode(secret1, 6);//calling method decode and pass string array and integer number
decode(secret2, 4);//calling method decode and pass string array and integer number
decode(secret3, 4);//calling method decode and pass string array and integer number
decode(secret4, 5);//calling method decode and pass string array and integer number
return 0;
}
output:
Please find the attachment.
Step-by-step explanation:
In the above C++ language code, a method "decode" is declared that accepts a string array and an integer variable in its parameter, inside the method a for loop is declared, which is used "n" variable to print its
letter value in the given string value.
In the main method, 4 string array "secret1, secret2, secret3, and secret4" is declared which assigns some value, and then we call the method "decode" and pass string array value and an integer value in its parameter.