Computer Science, asked by motiver99, 7 months ago

17-1 The current selected programming language is C. we emphasize the submission of a fully working code over partially correct but efficient code. Once submitted you cannot review this problem again. You can use printf() to debug your code. The printf() may not work in the case of syntax/runtime error. The version of GCC being used is 5.5.0.

A company has a sales record of N products for M days. The company wishes to know the maximum revenue received from a given product of the N products each day Write an algorithm to find the highest revenue received each day.

Input
The first line of the input consists of two space-separated integers- days (M) and products (N), representing the days and the products in the sales record.
The next M lines consist of N space- separated integers representing the sales revenue received from each product each day.
Output
Print M space-separated integers representing the maximum revenue received each day.

Answers

Answered by sarahssynergy
32

Given below is required program C- programming language.

Explanation:

  • #include<stdio.h>
  • int main(){
  •    int n, m;
  •    printf("Enter the number of days and products:" );
  •    scanf("%d %d", &m, &n);
  •    int arr[m][n];
  •    for(int j=0;j<m;j++){
  •          printf("Enter day %d 's sales:\n" ,(j+1));
  •          for(int i=0;i<n;i++){  
  •                    printf("Revenue by product %d:" , (i+1));
  •                    scanf("%d" , &arr[j][i]);  } }
  •    for(int j=0;j<m;j++){
  •        for(int i=0; i<n;i++){
  •             if (arr[j][0] < arr[j][i]) {   arr[j][0] = arr[j][i];     }  }
  •        printf("The highest revenue on day %d = %d", (j+1), arr[j][0]); }
Similar questions