/*
Write a function which return min and max value from an array
*/
#include<stdio.h>
void minmax();
void main()
{
int i,n,minValue,maxValue;
printf("Enter the size of array:\n");
scanf("%d",&n);
int array[n];
printf("Enter array elements :\n");
for(i=0;i<n;i++)
{
scanf("%d",&array[i]);
}
minValue = array[0];maxValue=array[0];
minmax(array,n,&minValue,&maxValue);
printf("Minimum value is %d and maximum value is %d ",minValue,maxValue);
}
void minmax(int* array,int n,int* minValue,int* maxValue)
{
int i;
for(i=0;i<n;i++)
{
if(*(array+i) < *minValue )
*minValue = *(array+i);
if(*(array+i) > *maxValue )
*maxValue = *(array+i);
}
}
Write a function which return min and max value from an array
*/
#include<stdio.h>
void minmax();
void main()
{
int i,n,minValue,maxValue;
printf("Enter the size of array:\n");
scanf("%d",&n);
int array[n];
printf("Enter array elements :\n");
for(i=0;i<n;i++)
{
scanf("%d",&array[i]);
}
minValue = array[0];maxValue=array[0];
minmax(array,n,&minValue,&maxValue);
printf("Minimum value is %d and maximum value is %d ",minValue,maxValue);
}
void minmax(int* array,int n,int* minValue,int* maxValue)
{
int i;
for(i=0;i<n;i++)
{
if(*(array+i) < *minValue )
*minValue = *(array+i);
if(*(array+i) > *maxValue )
*maxValue = *(array+i);
}
}
No comments :
Post a Comment