Menu
CoddyTech

Recap Challenge #2

Part of the Fundamentals section of Coddy's C journey. Lesson 60 of 63.

challenge icon

Challenge

Easy

Let's test your array manipulation skills in C!

Create a program that performs operations on a 2D array (matrix):

  1. Create a function rotateMatrix that:
    • Takes the original matrix, a second matrix to fill with the rotated result, and the size
    • Rotates the matrix 90 degrees clockwise
      Use this to rotate the matrix: rotated[j][size-1-i] = original[i][j];
    • Writes the result into the second matrix (the function returns void; the given main prints it for you)
  2. Create a function findElement that:
    • Takes a 2D integer array, its size, and a target value
    • Returns 1 if the target is found in the matrix, 0 otherwise

Try it yourself

void rotateMatrix(int original[][10], int rotated[][10], int size) {
    // Your code here
}

int findElement(int matrix[][10], int size, int target) {
    // Your code here
}

All lessons in Fundamentals

Practice on your own: Online C compiler