# Write a C program to find both the largest and smallest number in a list of integers

In this article, we will write a C program to find both the largest and smallest number in a list of integers.

# Write a C program to find both the largest and smallest number in a list of integers

``````#include <stdio.h>
#include <conio.h>

void main()
{
int a[10], i, n, small, large;
clrscr();
printf("Enter The Array Size:");
scanf("%d", &n);
printf("ENTER ELEMENTS OF ARRAY");
for (i = 0; i < n; i++)	// read the elements of an array
scanf("%d", &a[i]);
small = a[0];
large = a[0];
for (i = 0; i < n; i++)	// read the elements of an array
{
if (a[i] < small)	// check the condition for minimum value
small = a[i];
if (a[i] > large)	//check the condition for maximum value
large = a[i];
}
printf("largest value is:%d\n", large);
printf("smallest value is:%d\n", small);
getch();
}
``````

INPUT:

``````Enter The Array Size:10
ENTER THE ELEMENTS OF ARRAY
7 10 9 8 6 5 2 3 4 1
``````

OUTPUT:

`````` largest value is : 10
smallest value is : 1 ``````