0% found this document useful (0 votes)
118 views

C Program To Find The Frequency of Odd Numbers and Even Numbers in The Input of A Matrix

This C program takes a matrix as input from the user and counts the frequency of odd and even numbers within the matrix. It prompts the user to enter the order of the matrix, then the values of the matrix. It then prints out the matrix, and calculates the number of odd and even values, outputting the frequencies.

Uploaded by

tejagella
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

C Program To Find The Frequency of Odd Numbers and Even Numbers in The Input of A Matrix

This C program takes a matrix as input from the user and counts the frequency of odd and even numbers within the matrix. It prompts the user to enter the order of the matrix, then the values of the matrix. It then prints out the matrix, and calculates the number of odd and even values, outputting the frequencies.

Uploaded by

tejagella
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

/* C program to find the frequency of odd numbers and even numbers in the input of a matrix */ #include <stdio.

h> void main () { static int ma[10][10]; int i,j,m,n,even=0,odd=0; printf (Enter the order ofthe matrix \n); scanf (%d %d,&m,&n); printf (Enter the coefficients if matrix \n); for (i=0;i<m;++i) { for (j=0;j<n;++j) { scanf (%d, &ma[i][j]); if ((ma[i][j]%2) == 0) { ++even; } else ++odd; } } printf (The given matrix is\n); for (i=0;i<m;++i) { for (j=0;j<n;++j) { printf ( %d,ma[i][j]); } printf (\n); } printf (\nThe frequency of occurrence of odd number = %d\n,odd); printf (The frequency of occurrence of even number = %d\n,even); } /* End of main() */

/* Output Enter the order of the matrix 33 Enter the coefficients if matrix

123 456 789 The given matrix is 123 456 789 The frequency of occurrence of odd number = 5 The frequency of occurrence of even number = 4

You might also like