bsc

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

assignment-p-06.c (1131B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a C program that includes a user-defined function named findLargest with the
      9 signature int findLargest(int arr[], int size);. The function should take an array of integers
     10 and its size, and return the largest element in the array. */
     11 
     12 #include <stdio.h>
     13 
     14 void inputArray(int[], int);
     15 int findLargest(int[], int);
     16 
     17 int main()
     18 {
     19     int size;
     20     printf("How many element do you want to enter: ");
     21     scanf("%d", &size);
     22     int arr[size];
     23     inputArray(arr, size);
     24     printf("\nLargest Element is: %d", findLargest(arr, size));
     25     return 0;
     26 }
     27 
     28 void inputArray(int arr[], int size)
     29 {
     30     int i;
     31     for (i = 0; i < size; i++)
     32     {
     33         printf("Enter element %d: ", i + 1);
     34         scanf("%d", &arr[i]);
     35     }
     36 }
     37 
     38 int findLargest(int arr[], int size)
     39 {
     40     int largest = arr[0], i;
     41     for (i = 1; i < size; i++)
     42     {
     43         if (largest < arr[i])
     44         {
     45             largest = arr[i];
     46         }
     47     }
     48     return largest;
     49 }
© 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