Ms. Seena has brought 10 items and she wants to print the item with minimum and maximum cost. Write a software program to do it.
#include <stdio.h>
int main()
{
double arr[] = {1.2, 3.5, 7.8, 4.5, 2.6, 9.0, 3.6, 5.7, 2.8, 8.9};
double max = 0.0, min = 10000.0;
for(int i = 0; i != 10; ++i)
{
if(arr[i] > max)
{
max = arr[i];
}
if(arr[i]<min)
{
min = arr[i];
}
}
printf("Maximum cost: %f\n", max);
printf("Minimum cost: %f\n", min);
return 0;
}
Comments
Leave a comment