generated from Pooja-M-R/arrays-and-loops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program-10.c
40 lines (31 loc) · 829 Bytes
/
Program-10.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
//INPUT - 4 30 20 10 60
//OUTPUT: The largest and smallest elements are 60 and 10
//INSERT THE MISSING CODE
#include <stdio.h>
int main()
{
int arr[100], n, i, small, large;
printf("Enter how many values you want to read and values");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
//printf("Enter the value of a[%d] : ",i);
scanf("%d", &arr[i]);
}
small = arr[0];
large = arr[0];
for (i = 1; i < n; i++)
{
if (arr[i] < small )//missing code
{
small = arr[i];//missing code
}
if (arr[i] >large )//missing code
{
large= arr[i];//missing code
}
}
printf("The largest element of the array = %d", large);
printf("The smallest element of the array = %d", small);
return 0;
}