Programming Examples
C program to find the minimum of the 8 floating point numbers and its place in the array
Write a ‘C’ program to find the minimum of the 8 floating point numbers and its place in the array.
Solution
#include<stdio.h>
int main()
{
float num[8],min;
int a,pos=0;
printf("Enter any 8 Floating point numbers for array ");
for(a=0;a<8;a++)
{
scanf("%f",&num[a]);
}
min=num[0];
for(a=1;a<8;a++)
{
if(min>num[a])
{
min=num[a];
pos=a;
}
}
printf("Minimum value of array is: %f and it placed on %d index",min,pos);
return 0;
}
Output
Enter any 8 Floating point numbers for array
4.5
7.8
5.6
2.4
6.7
5.6
8.9
5.6
Minimum value of array is: 2.400000 and it placed on 3 index