Answer to Question #294264 in C for Pacan

Question #294264

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. 


1
Expert's answer
2022-02-06T03:52:08-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS