Recap Challenge #2
Part of the Fundamentals section of Coddy's C journey. Lesson 60 of 63.
Challenge
EasyLet's test your array manipulation skills in C!
Create a program that performs operations on a 2D array (matrix):
- Create a function
rotateMatrixthat:- 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 givenmainprints it for you)
- Create a function
findElementthat:- 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
3Operators
Arithmetic OperatorsModulo OperatorIncrement/DecrementAssignment OperatorsRelational OperatorsLogical Operators Part 1Logical Operators Part 2Logical Operators Part 3Recap ChallengePractice on your own: Online C compiler