1: #include<stdio.h>
2: int main(){ 3: int a[50],size,i,j=0,big,secondbig;
4: printf("Enter the size of the array: "); 5: scanf("%d",&size); 6: printf("Enter %d elements in to the array: ", size); 7: for(i=0;i<size;i++)
8: scanf("%d",&a[i]); 9:
10: big=a[0];
11: for(i=1;i<size;i++){ 12: if(big<a[i]){ 13: big=a[i];
14: j = i;
15: }
16: }
17:
18: secondbig=a[size-j-1];
19: for(i=1;i<size;i++){ 20: if(secondbig <a[i] && j != i)
21: secondbig =a[i];
22: }
23:
24: printf("Second biggest: %d", secondbig); 25: return 0;
26: }
27:
28:
Comments
Post a Comment