Company: Cisco_22_feb
Difficulty: medium
Below is a program that prints matrix elements in spiral order, moving clockwise from the outer edges toward the center. Spiral traversal visits elements by going left-to-right across the top row, then top-to-bottom down the right column, then right-to-left across the bottom row, then bottom-to-top up the left column, and repeating this pattern for inner layers. For example, a 3x3 matrix with values 1-9 would output: 1 2 3 6 9 8 7 4 5. The input consists of the matrix dimensions followed by the matrix elements. However, this program has errors which prevent it from achieving its intended task. Can you please make corrections to make the program work?