Uploaded by Blessa Mae Belgira Uchi

CC104 Stack(2)

advertisement
GREEN VALLEY COLLEGE FOUNDATION, INC.
Km.2, Bo.2, Gensan Drive., Koronadal City South Cotabato
INSTRUCTIONAL MATERIALS
SCHOOL OF ENGINEERING AND TECHNOLOGY
Document Code:
FM-DEA-031
Issue No: 01
Revision No: 00
Effectivity Date: June 4, 2020
Page No: Page 1 of 1
Self-Check Assessment
Write a program that reverses a word entered by the user.
Hints:
•
Use an array to implement the stack data structure (LIFO).
•
Use a scanner to scan data from the user.
Output:
Enter a word: program
stack[0] = p
stack[1] = r
stack[2] = o
stack[3] = g
stack[4] = r
stack[5] = a
stack[6] = m
Result: margorp
Download