Lab 17
Lab 17
#include <stdio.h>
return sum;
}
int main() {
int rows, cols;
int arr[rows][3];
printf("The sum of the elements in the 2-D array is: %d\n", sum);
return 0;
}
2)Write a C program to determine the sum of main diagonal elements of a 2-D array of size 3x3
using a function SUMDIAGONAL.
#include <stdio.h>
return sum;
}
int main() {
int arr[3][3];
return 0;
}
return largest;
}
return smallest;
}
int main() {
int rows, cols;
int arr[rows][3];
return 0;
}
4)Write a C program to find the sum of only PRIME values in a 2-D array using a function
PRIMESUM.
#include <stdio.h>
return 1;
}
return sum;
}
int main() {
int rows, cols;
int arr[rows][3];
printf("The sum of prime values in the 2-D array is: %d\n", primeSum);
return 0;
}
5)Write a C program to perform addition of two matrices and display the result using 3 rd matrix.
#include <stdio.h>
int main() {
int rows, cols;
// Perform matrix addition and store the result in the third matrix
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
result[i][j] = matrix1[i][j] + matrix2[i][j];
}
}
return 0;
}