Question
Written in C++, used in code blocks. I am stuck on writing the code for the sum of diagonal elements. This is what i have
Written in C++, used in code blocks. I am stuck on writing the code for the sum of diagonal elements. This is what i have so far.
#include
#define SIZE 4
int main() { int A[SIZE][SIZE]; int row, col, sum = 0; int d_sum = 0;
// Wasn't sure how to display the matrix, but I got it so you type in the table exactly how you see it and it will output everything correctly. //This function below prints your table printf("Enter elements in matrix of size %dx%d: ", SIZE, SIZE); for(row=0; row printf("Sum of elements of Row %d = %d ", row+1, sum); } // This function prints all the column sums for(row=0; row printf("Sum of elements of Column %d = %d ", row+1, sum); } // This function prints the diagonal sum. for(row=0; row return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started