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; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;
}

Expert Solution
Step 1

Below is the updated code and sample output:

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education