
I have also made a video on the same topic. I hope you have understood both these programs with logic. This program will rotate the matrix in an anti-clockwise direction by 90 degrees. Matrix Rotation in C By 90 Degree Clockwise #include Īlso Read: Reverse a Number using getchar and putchar function in c Matrix Rotation in C By 90 Degree Anti-Clockwise #include Īlso Read: C Program to Print Numbers Except Multiples of n Here, I have written two separate c programs for matrix rotation i.e. I recommend you to learn arrays in c programming for understanding this program.Īlso Read: C Program to Remove Zeros from a number If you want to rotate by 90 degrees, you would first exchange the x, and ys, then, since either one or the other will have to change sign, multiply one of them by -1, depending on whether you want to go clockwise or counterclockwise Kbotat 20:11.

Have you observed any change in both the diagrams? In the second figure, we are rotating the matrix to the left side from the right side i.e. Matrix Rotation in C – 90 Degrees Anti- Clockwise Matrix Rotation in C 90 Degrees Anti-Clockwise Similarly, we are going to rotate the same matrix by 90 degrees anticlockwise. Matrix Rotation in C 90 Degrees Clockwise In simple words, we can say that we are rotating the matrix from left to right. To flip 180 degrees, simply click one direction. You can see how this matrix will look like after rotating about 90 degrees clockwise. Every time you click either Clockwise or Counterclockwise, the PDF will rotate 90 degrees in that direction. In the following diagram, we are rotating the 3*3 matrix by 90 degrees clockwise. Before writing the c program for this, let us see the following figures.Īlso Read: Switch Case in C Program to Calculate Area of Circle and Triangle Matrix Rotation in C – 90 Degrees Clockwise Is clockwise left or right Clockwise involves a turn to the right, following the direction of the hands of a clock.

You can use this rule to rotate a pre-image by taking the points of each vertex, translating them according to the rule, and drawing the image. In this program, we will rotate the matrix by 90 degrees to both sides i.e. The general rule for rotation of an object 90 degrees is (x, y) > (-y, x). In this post, I am going to write a program for matrix rotation in c.
