From the course: Level Up: C

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Rotating a matrix

Rotating a matrix - C Tutorial

From the course: Level Up: C

Rotating a matrix

(stars dinging) (bright music) - [Instructor] Your C challenge is to rotate a grid 90 degrees clockwise. A matrix is like a grid, a two-dimensional array of rows and columns. Assume the grid is a five-by-five array. Have the grid initially filled with random characters. Rotate the grid 90 degrees clockwise. Then output the rotated grid. Pause the video now to... Wait a second. This challenge is way too easy. Let me start over. (tape rewinding) (stars dinging) (bright music) A matrix doesn't always have to be the same number of rows and columns. Some are uneven. Yet they may still need to be rotated. For this challenge, rotate three matrices, one three-by-eight, one five-by-five, and the last, six-by-four. Initialize each matrix with random characters. Output the original. Rotate it. Then output the rotated matrix. Here is sample output for my solution. These characters are random, but you can see…

Contents