This is a C Program which finds the smallest largest element in an array.
Here initially first element in array and its next element are compared array[0] and array[1] , if array[0] is greater, then the value is stored in array[0] and now the second element is increased 2 .3 4 .. until the last element is reached.
PROGRAM :
OUTPUT :
Related Programs :
Here initially first element in array and its next element are compared array[0] and array[1] , if array[0] is greater, then the value is stored in array[0] and now the second element is increased 2 .3 4 .. until the last element is reached.
PROGRAM :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n;
printf("How many numbers ?\t");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("\nEnter number %d: \t",i+1);
scanf("%d",&array[i]);
}
for(i=0;i<n;i++)
{
if(array[0]>array[i])
array[0]=array[i];
}
printf("The smallest among the %d numbers is %d",n,array[0]);
return 0;
}
OUTPUT :
| C - Smallest Element in an Array |
Related Programs :
Descending Order( Java )
Smallest Element in an Array( C )
Largest Element in an Array( C )
Smallest Element in an Array( C )
Ascending Order( C )
Descending Order( C )
Largest Element in an Array( C )
Smallest Element in an Array( C )
Ascending Order( C )
Descending Order( C )
Sum Of Elements in an Array( Java )
Largest Elements in an Array( Java )
Smallest Element in an Array( Java )
Ascending Order( Java )
Even and Odd numbers in an Array( Java )
Smallest Element in an Array( Java )
Ascending Order( Java )
Even and Odd numbers in an Array( Java )
No comments:
Post a Comment