forked from kushalsingh-00/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp3.c
More file actions
30 lines (28 loc) · 686 Bytes
/
p3.c
File metadata and controls
30 lines (28 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
-------------------------------------------------------
Name : Pointer
Author : Kushal Singh Rathore
Discription : Min And Max Value Of Array By Pointer
-------------------------------------------------------
*/
#include<stdio.h>
void minMax(int arr[],int len,int *min,int *max)
{
*min=*max=arr[0];
for(int i=1;i<len;i++)
{
if(arr[i]<*min)
*min=arr[i];
if(arr[i]>*max)
*max=arr[i];
}
}
int main()
{
int a[]={3,4,6,2,34,63,53,23,54,45,234};
int min,max;
int len=sizeof(a)/sizeof(a[0]);
minMax(a,len,&min,&max);
printf("Minimum value is: %d and Maximum value is: %d",min,max);
return 0;
}