Answer to Question #255057 in C for Chs

Question #255057

A shop had N number of sales each day for M days. Each day different types of items were sold and had different profits associated with them, but the quantity of items sold each day was the same. The owner of the shop wishes to know the minimum profit made each day. For this, a structure was formed in which profit for all different items for an individual day was kept in the same column for M days.


Write an algorithm to find the minimum profit for each day individually.


Input


The first line of the input con beats of


1
Expert's answer
2021-10-22T16:45:51-0400
#include <stdio.h>


int main()
{
    int M, N;
    printf("\nEnter number of items: ");
    scanf("%d",&N);
    printf("\nEnter number of days: ");
    scanf("%d",&M);
    int profit [M][N];
    for(int i=0;i<M;i++){
        printf("\nEnter profit for each item on day %d:",(i+1));
        for(int j=0;j<N;j++){
            printf("\nProfit for item %d: ",(j+1));
            scanf("%d",&profit[i][j]);
        }
    }
    for(int i=0;i<M;i++){
        printf("\nMininum profit on day %d is: ",(i+1));
        int min=profit[0][0];
        for(int j=0;j<N;j++){
            if(profit[i][j]<min){
                min=profit[i][j];
            }
        }
        printf("%d",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