forked from PrabhudeepSingh/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinMaxArray.c
More file actions
39 lines (33 loc) · 692 Bytes
/
MinMaxArray.c
File metadata and controls
39 lines (33 loc) · 692 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
31
32
33
34
35
36
37
38
39
//program to find the minimum and maximum number in an array
#include<stdio.h>
int main()
{
int i,n;
float a[20],max,min;
printf("Enter total number of elements of you want to enter : ");
scanf("%d",&n);
while(n<=0||n>20)
{
printf("\nError... Range of elements is 0 - 20 ");
printf("\nEnter the number of elements again : ");
scanf("%d",&n);
}
printf("\n");
for(i=0;i<n;i++)
{
printf("Enter the %d element : ",i+1);
scanf("%f",&a[i]);
}
max=a[0];
min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("\nMaximum number is : %.2f",max);
printf("\nMinimum number is : %.2f",min);
return 0;
}