# Minimum Maximum using Pointers coderinme

#### Minimum Maximum using Pointers coderinme

Minimum Maximum using Pointers coderinme
Write a function that returns the minimum and maximum value in an array of integers. Inputs to the function are the array of integers, an integer variable containing the length of the array and pointers to the integer variable that will contain the minimum and maximum values. The function’s prototype is:
void maxmin(int array[],int length,int*min,int*max);

``````#include<stdio.h>
void minmax(int a[],int len,int *min,int *max)
{
int i;
*max = a[0];
*min = a[0];
for(i = 0 ; i < len ; i++)
{
if(*max < a[i])
*max = a[i];
if(*min > a[i])
*min = a[i];
}
}
int main()
{
int a[100],i,len,min,max;
printf("\nPlease enter the length of array:");
scanf("%d",&len);
for(i = 0 ; i < len ; i++)
{
printf("Enter the a[%d] values: ",i);
scanf("%d",&a[i]);
}
minmax(a,len,&min,&max);
printf("\nMaximum values is: %d \nMinimum value is: %d",max,min);
getch();
return 0;
}``````

For more programs in C, visit our C Coder Archives

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme