Giango Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

#include <stdio.

h>

int main() {
int a[10][10], b[10][10], c[10][10], sum[10][10], rows, columns, i, j;
float average[10][10];

printf("Enter the number of rows: ");


scanf("%d", &rows);

printf("Enter the number of columns: ");


scanf("%d", &columns);

if (rows < 1 || columns < 1 || rows > 10 || columns > 10) {


printf("Invalid number of rows or columns\n");
}

for (i = 0; i < rows; i++) {


for (j = 0; j < columns; j++) {
printf("MATRIX A - Enter row %d, column %d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}
}

for (i = 0; i < rows; i++) {


for (j = 0; j < columns; j++) {
printf("MATRIX B - Enter row %d, column %d: ", i + 1, j + 1);
scanf("%d", &b[i][j]);
}
}

for (i = 0; i < rows; i++) {


for (j = 0; j < columns; j++) {
printf("MATRIX C - Enter row %d, column %d: ", i + 1, j + 1);
scanf("%d", &c[i][j]);
}
}
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
sum[i][j] = a[i][j] + b[i][j] + c[i][j];
average[i][j] = sum[i][j] / (rows * columns);
}
}

printf("Matrix A:\n");
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
printf("%d ", a[i][j]);
}
printf("\n");
}

printf("Matrix B:\n");
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
printf("%d ", b[i][j]);
}
printf("\n");
}

printf("Matrix C:\n");
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
printf("%d ", c[i][j]);
}
printf("\n");
}

printf("Sum of Matrices A, B, and C:\n");


for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
printf("%d ", sum[i][j]);
}
printf("\n");
}

printf("Average of Matrices A, B, and C:\n");


for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
printf("%.2f ", average[i][j]);
}
printf("\n");
}

return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy