You are viewing a single comment's thread from:
RE: Hi, this is a test post, its main purpose will be posts in comments.
#include <stdio.h>
//Function to find the largest element
int largestElement(int arr[], int size)
{
int max = arr[0];
for (int i = 1; i < size; i++)
if (arr[i] > max)
max = arr[i];
return max;
}
//Function to find the smallest element
int smallestElement(int arr[], int size)
{
int min = arr[0];
for (int i = 1; i < size; i++)
if (arr[i] < min)
min = arr[i];
return min;
}
// main()
int main()
{
int arr[] = {10, 324, 45, 90, 9808};
int n = sizeof(arr)/sizeof(arr[0]);
printf("Largest element in array is: %d \n", largestElement(arr, n));
printf("Smallest element in array is: %d \n", smallestElement(arr, n));
return 0;
}