-
Notifications
You must be signed in to change notification settings - Fork 1
/
q1.c
45 lines (40 loc) · 815 Bytes
/
q1.c
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
40
41
42
43
44
45
/***********************************************************
Program to find the largest and the smallest element
of the array
Author: leonatwork(Noel Aby Das)
**********************************************************/
#include<stdio.h>
void minmax(int a[],int n)
{
int min,max,i,j;
min=max=a[0];
for(i=1;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("maximum element : %d\nminimum element : %d\n",max,min);
}
void main()
{
int a[10],i,n;
label:
printf("Enter the number of elements in array : ");
scanf("%d",&n);
if(n<=0)
{
printf("Invalid size\nEnter again\n");
goto label;
}
else if(n>10)
{
printf("Array size too large\nenter smaller value\n");
goto label;
}
printf("Enter %d elements : \n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
minmax(a,n);
}