Posts

Showing posts from April, 2021

WAP that finds the sum of min and max of a mxn matrix

Image
Here is your code :- #include <stdio.h> int main() {     int m, n, matrix[10][10], i, j, max, min;     printf("Enter the order of the matrix : ");     scanf("%d%d", &m, &n);     printf("Enter the Element of Matrix: ");   // Input of elements of matrix.     for (i=0; i<m; i++) {         for (j=0; j<n; j++) {             scanf("%d", &matrix[i][j]);         }     } // Initialisation of max and min to be     max = matrix[0][0];     min = matrix[0][0];     for (i=0; i<m; i++) {         for (j=0; j<n; j++) {             if (max < matrix[i][j]){             m...

WAP to find frequency of element in C

Image
 Here is your code in C - #include <stdio.h> int main() {     int a[5], i, freq=0, key;          printf("Enter the elements of array: ");          for (i=0; i<5; i++) {         scanf("%d", &a[i]);     }          printf("Enter the element whose frequency you want to find: ");          scanf("%d", &key);          for (i=0; i<5; i++) {         if (key == a[i])         freq ++;     }          printf("\nFrequency of %d is %d", key, freq);       return 0; } Output -