Find maximum and minimum number - C Programming Language | Chetan TM

# Question: Find maximum and minimum number providing no of inputs

/* Find maximum and minimum */
/* Program Coded By Chetan Thapa Magar */

#include<stdio.h>
#include<conio.h>
#include<math.h>
int max(int a[], int, int);
int min(int b[], int, int);
void main()

int i, n, a[50], big, small;
printf("Enter how many numbers:\t");
scanf("%d", &n);
printf("\nEnter the number one by one:\n");
for(i=0; i<n; i++)
scanf("%d", &a[i]);
big=a[0];
small=a[n-1];
printf("\nThe maximum value is %d", max(a, n, big));
printf("\nThe minimum value is %d", min(a, n, small));
getch();
}

int max(int a[], int n, int big)
{
if(n==0)
return big;
else
n--;
if(a[n]>big)
big=a[n];
return(max(a,n,big));
}
int min(int a[], int n, int small)
{
if(n==0)
return small;
else
n--;
if(a[n]<small)
small=a[n];
return min(a, n, small);
}

Output / Execution:

Enter how many numbers: 5
Enter the numbers one by one

14
56
34
63
45

The maximum value is 63
The minimum value is 14

# C Programming:

Name

ltr
item
Chetan TM: Find maximum and minimum number - C Programming Language
Find maximum and minimum number - C Programming Language
Tutor Chetan C Programming Language Question: Find maximum and minimum number providing no of inputs
https://1.bp.blogspot.com/-RGmEMG-49eA/XtCQx7D6wJI/AAAAAAAABOU/6CDCGlQx6zc-9F6FLCshm76vStbNq6pmACLcBGAsYHQ/s16000/Part%2B1.jpg
https://1.bp.blogspot.com/-RGmEMG-49eA/XtCQx7D6wJI/AAAAAAAABOU/6CDCGlQx6zc-9F6FLCshm76vStbNq6pmACLcBGAsYHQ/s72-c/Part%2B1.jpg
Chetan TM
http://www.chetantm.com.np/2021/03/find-maximum-and-minimum-number-c.html
http://www.chetantm.com.np/
http://www.chetantm.com.np/
http://www.chetantm.com.np/2021/03/find-maximum-and-minimum-number-c.html
true
5092578752892144998
UTF-8