#include <stdio.h>
int main() {
int arr[10]={23,43,12,18,6,48,39,65,43,-3};
int max = arr[0];
int min = arr[0];
int i;
for(i=1;i<10;i++)
{
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
printf("the maximum number of the array is %d ",max);
printf("\nthe minimum number of the array is %d ",min);
//find second maximium and minimum number of the array
int max2=min;
int min2=max;
for(i=0;i<9;i++)
{
if(arr[i]!=max && arr[i]>max2)
{
max2=arr[i];
}
if(arr[i]!=min && arr[i]<min2)
{
min2=arr[i];
}
}
printf("\nthe second maximum number is %d ",max2);
printf("\nthe second minimum number is %d ",min2);
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter