For this exercise you are to write a program (in C or C++ preferably) that reads a text file containing a number of words and displays the words on the screen in reverse order using a stack. An algorithm of the program is shown below:
Begin main
Display a prompt for the file name
Read in the file name
Try to open the file
If the file fails to open
Print an error message on the screen and exit
Loop
Read in a word from the file
If the file read fails, terminate (break) the loop
Push the word onto the stack
End loop
Close the file
While the stack is not empty
Display the top stack word on the screen followed by a space
Pop the top value from the stack
End while
End main
Do not implement the stack using a class or struct or with STL. The stack must be implemented using a fixed size array of words and an index integer for indicating the top of the stack. The stack array and index should be global variables. A word can be a string or a c-string (i.e. a character array). You can assume no word is more than 20 characters long. The stack functions (i.e. push(), top(), pop(), isEmpty() ) should be implemented below the main() and prototyped above the main().