Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
638 B
1
Indexable
Never
#include <stdio.h>

int main() {
    int M, N;
    printf("Enter the number of rows (M): ");
    scanf("%d", &M);
    printf("Enter the number of columns (N): ");
    scanf("%d", &N);

    int matrix[M][N];

    printf("Enter the elements of the matrix:\n");
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &matrix[i][j]);
        }
    }

    printf("Elements in rows with even numbers:\n");
    for (int i = 1; i < M; i += 2) {
        for (int j = 0; j < N; j++) {
            printf("%d ", matrix[i][j]);
        }
        printf("\n");
    }

    return 0;
}
Leave a Comment