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
#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;
}
Comments
Leave a comment