Answer to Question #292098 in C for mahi7781

Question #292098

3. 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-01-30T07:27:34-0500
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int items[10], min, max;
    for (int i = 0; i < 10; i++) {
        printf("Enter the price for item %d: ", i+1);
        scanf("%d", &items[i]);
    }
    min = max = items[0];
    for (int i = 1; i < 10; i++) {
        if (min > items[i]) {
            min = items[i];
        }
        if (max < items[i]) {
            max = items[i];
        }
    }
    printf("The minimum price is %d.\n", min);
    printf("The maximum price is %d.\n", max);
    return 0;
}

Enter the price for item 1: 230
Enter the price for item 2: 560
Enter the price for item 3: 190
Enter the price for item 4: 600
Enter the price for item 5: 100
Enter the price for item 6: 549
Enter the price for item 7: 32
Enter the price for item 8: 45
Enter the price for item 9: 98
Enter the price for item 10: 230
The minimum price is 32.
The maximum price is 600.

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