i am suppossed to write a program using an array of strings to hold the words of the ICAO alphabet, and index the array by the positions of the letters of the alphabet. I started it off but cannot figure it out please help!!
#include <iostream>
const int n_row=26;
const int n_col=2;
const char tarray(n_row)(n_col)= {
{‘A’, ‘Alpha’},
{‘B’, ‘Bravo’},
{‘C’, ‘Charlie’},
{‘D’, ‘Delta’},
{‘E’, ‘Echo’},
{‘F’, ‘Foxtrot’},
{‘G’, ‘Golf’},
{‘H’, ‘Hotel’},
{‘I’, ‘India’},
{‘J’, ‘Juliet’},
{‘K’, ‘Kilo’},
{‘L’, ‘Lima’},
{‘M’, ‘Mike’},
{‘N’, ‘November’},
{‘O’, ‘Oscar’},
{‘P’, ‘Papa’},
{‘Q’, ‘Quebec’},
{‘R’, ‘Romeo’},
{‘S’, ‘Sierra’},
{‘T’, ‘Tango’},
{‘U’, ‘Uniform’},
{‘V’, ‘Victor’},
{‘W’, ‘Whiskey’},
{‘X’, ‘X-Ray’},
{‘Y’, ‘Yankee’},
{‘Z’, ‘Zulu’} };
void main()
{
char phrase[80], holdPhrase[80], letter, answer;
int x, y;
cout<<Enter a Phrase;
cin.getline(phrase, 79);
int sizeOfPhrase = strlen(phrase);
for (x=0; x< sizeOfPhrase; x++)
{
if (phrase[x]== ’ ‘)
holdPhrase[x]= ’ ‘;
else
holdPhrase[x]= ’-‘;
}
holdPhrase[x]=’\0’;
cout<<endl<<holdPhrase<<endl;
int found=0;
do
{
cout<<Enter a letter please :;
cin>>letter;
found =0;
for (y=0; y< sizeOfPhrase; y++)
{
if (letter == phrase[y]
{
found =1;
holdPhrase[y]=letter;
}
}
if (found ==0)
cout <<endl<<Letter<<letter<<not in phrase.;
else
cout <<endl<<holdPhrase<<endl;
cout<<\n\nContinue y/n:;
cin>>ans;
}
while (toupper(ans) !=’N’);
cout <<\n\n Program completed, \n;
}