Answer:
The program in c language are as follows-
Program:
#include <stdio.h>
int main()
{
int a[10],i,largest_number,smallest_number;//declare the variable
for(i=0;i<10;i++)// loop to assign the value of array.
scanf("%d",&a[i]); //Statement to assign the value.
largest_number=a[0]; // assign first array value to be largest.
smallest_number=a[0]; // assign first array value to be smallest.
for(i=1;i<10;i++)// loop to check the value to smallest or highest.
{
if(a[i]>largest_number) // compare the new array value and largest value
largest_number=a[i]; // replace the value of largest_number to new largest value.
if(a[i]<smallest_number) // compare the new array value and smallest value
smallest_number=a[i]; // replace the value of largest_number to new largest value.
}
printf("largest number is %d and smallest number is %d", largest_number,smallest_number); // Print the largest and smallest value.
return 0; // return statement.
}
Output:
Firstly the user needs to give the 10 value as inputs--
1
2
0
3
4
2
7
3
9
10
Then it will print "largest number is 10 and smallest number is 0".
Explanation: