/*Find minimum and maximum of the array and tell them where is the position*/
#include <stdio.h>
#include <stdlib.h>
void findMinimum(int arr[]);
void findMaximum(int arr[]);
int main() {
int arr[10]={1,223,3,4,-11,6,7,8,9,10};
int i;
int minimum=arr[0];
int maximum=arr[0];
int minindex=0;
int maxindex=0;
for(int i=0;i<10;i++)
{
if(arr[i]<minimum)
{minimum=arr[i];
minindex=i+1;
}
if(arr[i]>maximum)
{
maximum=arr[i];
maxindex=i+1;}
}
printf("\nthe minimum number of the array is %d at position %d",minimum,minindex);
printf("\nthe maximum number of the array is %d at index %d",maximum,maxindex);
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