#include <stdio.h>
int main(void)
{
//int i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15;
// printf("Please enter 16 digits between 1 and 16: ");
// scanf("%d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d , %d", &i0,&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8,&i9,&i10,&i11,&i12,&i13,&i14,&i15);
int array1[16] = {1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2};
//Call the method to sum all the rows. Create the new array to hold
//all of the sums. For-loop to print it to the screen
sumRows(array1);
//Call the method to sum all the columns. Create the new array to hold
//all of the column sums. For-loop to print it to the screen
int columnSum[4];
sumColumns(array1);
//Call the method to sum the two diagonals. Create a new array to hold
//the sums. For-loop to print it to the screen
int diagonalSum[2];
sumDiagonals(array1);
}
int sumRows(int array1[]) {
{
//Create the holder array
int rowSum[4];
//Traveses each "row" of the array
for(int i = 0; i < 15; i+=4){
rowSum[i/4] = array1[i] + array1[i+1] + array1[i+2] + array1[i+3];
}
for(int i = 0; i < 4; i++){
printf(rowSum[i]);
}
printf("\n");
}
int sumColumns(int array1[]);{
//Create the holder array
int columnSum[4];
//Traverse each "column" of the array
for(int i = 0; i < 4; i++){
columnSum[i] = array1[i] + array1[i+4] + array1[i+8] + array1[i+12];
}
//return columnSum;
for(int i = 0; i < 4; i++)
printf(columnSum[i]+" ");
printf("\n");
}
int sumDiagonals(int array1[]);{
//Create the holder array
int diagonalSum[2];
//Traverse both "diagonals" of the array
for(int i = 0; i < 1; i++){
diagonalSum[i] = array1[i] + array1[i+5] + array1[i+10] + array1[i+15];
diagonalSum[i+1] = array1[i+15] + array1[i+10] + array1[i+5] + array1[i];
}
//return diagonalSum;
{
for(int i = 0; i < 2; i++)
printf(diagonalSum[i]+" ");
}
}
}