QUESTION
Take N number of elements in an array and display the largest element in the array.
“TESTCASE_1”: “5\n10 200 20 2 4\n###—###SEPERATOR—###—\nLargest element=200”, “TESTCASE_2”: “7\n-10 20 -6 40 4 6 1\n###—###SEPERATOR—###—\nLargest element=40”, “TESTCASE_3”: “6\n2 12 -8 80 40 100\n###—###SEPERATOR—###—\nLargest element=100”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0
ANSWER
#include <stdio.h>
int main()
{
int array[100], maximum, size, c, location = 1;
scanf("%d", &size);
for (c = 0; c < size; c++)
scanf("%d", &array[c]);
maximum = array[0];
for (c = 1; c < size; c++)
{
if (array[c] > maximum)
{
maximum = array[c];
location = c+1;
}
}
printf("Largest element=%d", maximum);
return 0;
}