2.c

#include <stdio.h>

int main()

{

    int i,j,r,c,Ecount=0, Ocount=0;

    printf(“Enter number of rows and coloumns\n”);

    scanf(“%d%d”, &r, &c);

    int m1[r][c];

    printf(“Enter the elements of matrix :\n”);

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

        for(j=0; j<c; j++) {

            scanf(“%d”,&m1[i][j]);

        }

    }

    printf(“Entered matrices is: \n”);

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

        for(j=0; j<c;j++) {

            printf(“%d “,m1[i][j]);

        }

    printf(“\n”);

    }

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

        for(j=0; j<c;j++) {

            if(m1[i][j]%2==0)

            Ecount++;

            else{

            Ocount++;

            }

        }

    }

        printf(“The Even elements are :%d and odd elements are : %d”,Ecount, Ocount);

    return 0;

}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *