I have provided the code I have written. All I need you to do is to rewrite the code. I need you to rewrite the comments, rename all the variables, and shift the code. It should look different once you have edited it. I would like to see another format for this code. It is in C-Programming. I think it shouldn’t take so long. Take your time, please! I really appreciate any help you can provide! CODE STARTS HERE: #include int main() { int n, p; printf("Numer of Rows/Colums of sq matrix: "); scanf("%d", &n); printf("to the power of: "); scanf("%d", &p); int m[n][n]; int r[n][n]; int tmp[n][n]; printf("Elements\n"); for ( int b = 0 ; b < n ; b++ ) { for ( int d = 0 ; d < n ; d++ ) { printf("[%d][%d] = ", b+1, d+1); scanf("%d", &m[b][d]); r[b][d] = m[b][d]; } } int sum = 0; //you loop 1 time less of the power for (int i = 0; i < p - 1; i++) { for ( int b = 0 ; b < n ; b++ ) { for (int d = 0 ; d < n ; d++ ) { for (int k = 0 ; k < n ; k++ ) { sum += r[b][k]*m[k][d]; } tmp[b][d] = sum; sum = 0; } } for ( int b = 0 ; b < n ; b++ ) { for ( int d = 0 ; d < n ; d++ ) { //m[b][d] = r[b][d]; r[b][d] = tmp[b][d]; } } } printf("RESULT:-\n"); for (int c = 0 ; c < n ; c++ ) { for (int d = 0 ; d < n ; d++ ) { printf("%d ", r[c][d]); } printf("\n"); } getchar(); return 0; }
5. I have provided the code I have written. All I need you to do is to rewrite the code. I need you to rewrite the comments, rename all the variables, and shift the code. It should look different once you have edited it. I would like to see another format for this code. It is in C-Programming. I think it shouldn’t take so long. Take your time, please! I really appreciate any help you can provide!
CODE STARTS HERE:
#include <stdio.h>
int main() {
int n, p;
printf("Numer of Rows/Colums of sq matrix: ");
scanf("%d", &n);
printf("to the power of: ");
scanf("%d", &p);
int m[n][n];
int r[n][n];
int tmp[n][n];
printf("Elements\n");
for ( int b = 0 ; b < n ; b++ ) {
for ( int d = 0 ; d < n ; d++ ) {
printf("[%d][%d] = ", b+1, d+1);
scanf("%d", &m[b][d]);
r[b][d] = m[b][d];
}
}
int sum = 0;
//you loop 1 time less of the power
for (int i = 0; i < p - 1; i++)
{
for ( int b = 0 ; b < n ; b++ )
{
for (int d = 0 ; d < n ; d++ )
{
for (int k = 0 ; k < n ; k++ )
{
sum += r[b][k]*m[k][d];
}
tmp[b][d] = sum;
sum = 0;
}
}
for ( int b = 0 ; b < n ; b++ ) {
for ( int d = 0 ; d < n ; d++ ) {
//m[b][d] = r[b][d];
r[b][d] = tmp[b][d];
}
}
}
printf("RESULT:-\n");
for (int c = 0 ; c < n ; c++ )
{
for (int d = 0 ; d < n ; d++ )
{
printf("%d ", r[c][d]);
}
printf("\n");
}
getchar();
return 0;
}

Below is the updated code and sample output:
Step by step
Solved in 3 steps with 1 images









