//How to get minimum value in array.
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[5],i,smallest_value=0,j;
clrscr();
printf("Enter the value of an array:\n");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<4;i++)
{
if(arr[i]<arr[i+1])
{
arr[i+1]=arr[i];
smallest_value=arr[i];
}
else
{
arr[i+1]=arr[i+1];
smallest_value=arr[i+1];
}
}
printf("\nSmallest value:%d",smallest_value);
getch();
}
Output:
Enter the value of an array:24
52
12
63
25
Smallest value:12
No comments:
Post a Comment