bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / eduincs_exam / Paper-1_05-03-2026 / Qn-10.c

Qn-10.c (750B)


      1 /* Write a C program to find the maximum element in each row of a 2D 
      2 array and print the result. */
      3 
      4 #include <stdio.h>
      5 
      6 void findMax(int row, int col, int[row][col]);
      7 
      8 int main()
      9 {
     10     int row = 3, col = 3, i, j, val = 1;
     11     int arr[row][col];
     12     for (i = 0; i < row; i++)
     13     {
     14         for (j = 0; j < col; j++)
     15         {
     16             arr[i][j] = val++;
     17         }
     18     }
     19     findMax(row, col, arr);
     20     return 0;
     21 }
     22 
     23 void findMax(int row, int col, int arr[row][col])
     24 {
     25     int i, j;
     26     int max;
     27     for (i = 0; i < row; i++)
     28     {
     29         max = arr[i][0];
     30         for (j = 0; j < col; j++)
     31         {
     32             if(max < arr[i][j]) {
     33                 max = arr[i][j];
     34             }
     35         }
     36         printf("Max of row %d = %d\n", i, max);
     37     }
     38 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror