Skip to content

Commit

Permalink
Create Find largest element in an array
Browse files Browse the repository at this point in the history
Optimized code for finding the largest element in an array
  • Loading branch information
Anshitavaryani authored Oct 15, 2020
1 parent 0595266 commit 28327ae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Find largest element in an array
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>

int main() {
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
int loop, largest;

largest = array[0];

for(loop = 1; loop < 10; loop++) {
if( largest < array[loop] )
largest = array[loop];
}

printf("Largest element of array is %d", largest);

return 0;
}

0 comments on commit 28327ae

Please sign in to comment.