Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Largest and Second Largest number in an array
#include <stdio.h> int main() { int array[31] = {1, 101, 1, 231, 153, 45, 48, 49, 345, 985, 621, 4864, 3, 15, 32, 15, 4, 99, 51, 32, 478, 53, 21, 4, 50, 69, 7, 8, 9, 1}; int loop, largest, second; if(array[0] > array[1]) { largest = array[0]; second = array[1]; }else { largest = array[1]; second = array[0]; } for(loop = 2; loop < 30; loop++) { if( largest < array[loop] ) { second = largest; largest = array[loop]; }else if( second < array[loop] ) { second = array[loop]; } } printf("The largest number in the array is - %d \nThe second largest number in the array - %d \n", largest, second); return 0; }
run
|
edit
|
history
|
help
0
A_141124Burbuja
Conflito entre 4 threads
Sunday assignment late v3
extra causes class UK assisment
c union bytes affected
multiplication
B_141202_CADENA_NUMERO
ptr[]
ordenarcifrademenosamas
poinres1