I have a 10x10 array of numbers from 1 to 100. I'm trying to get the diagonal sum from top right to bottom left corner and then printing it. But I keep getting an error that I need a semicolon. I'll bold the part where it says I have the error.
Code:
#include<stdio.h>#include<stdlib.h>
int main(void)
{
int i,j;
int word[10][10];
int num = 1;
int diag_sum = 0, diag_sum_right = 0;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
word[i][j] = num;
num++;
}
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
printf("%d \t", word[i][j]);
}
printf("\n");
}
for(i=0;i<10;i++)
{
diag_sum += word[i][i];
}
for(i=9;j=0;i>0;j<10;i--;j++)
{
diag_sum_right += word[i][j];
}
printf("The sum of diagonal from left to bottom right is %d \n", diag_sum);
printf("The sum of diagonal from right to bottom left is %d \n", diag_sum_right);
system("pause");
return 0;
}