bsc

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

Qn-10.c (942B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 06 Mar 2026
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a C program to find the maximum element in each row of a 2D 
      9 array and print the result. */
     10 
     11 #include <stdio.h>
     12 
     13 void findMax(int row, int col, int[row][col]);
     14 
     15 int main()
     16 {
     17     int row = 3, col = 3, i, j, val = 1;
     18     int arr[row][col];
     19     for (i = 0; i < row; i++)
     20     {
     21         for (j = 0; j < col; j++)
     22         {
     23             arr[i][j] = val++;
     24         }
     25     }
     26     findMax(row, col, arr);
     27     return 0;
     28 }
     29 
     30 void findMax(int row, int col, int arr[row][col])
     31 {
     32     int i, j;
     33     int max;
     34     for (i = 0; i < row; i++)
     35     {
     36         max = arr[i][0];
     37         for (j = 0; j < col; j++)
     38         {
     39             if(max < arr[i][j]) {
     40                 max = arr[i][j];
     41             }
     42         }
     43         printf("Max of row %d = %d\n", i, max);
     44     }
     45 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror