0 votes
107 views
in General by (0 points)
closed by
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 case of syntax/runtime error. The version of GCC being used is 5.5.0.
products for M days. The company wishes to know the maximum

A company has a sales record of N revenue received from a given product of the N products each day. Write an algorithm to find the highest revenue received each day.
closed

1 Answer

0 votes
by (0 points)
 
Best answer
An algorithm refers to the logical list of methods or stages utilized to solve a particular problem.

Typically, the process is done by a computer.

The algorithm should contain the following characteristics:

The algorithm should be easy to understand.
There should be no ambiguity.
It should have a one-of-a-kind answer to the problem.
The solution should be reached in a finite number of steps.
An algorithm to find the highest revenue each day is as follows-


#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]); }

Related questions

0 votes
1 answer 73 views
0 votes
1 answer 39 views
0 votes
1 answer 47 views

2.8k questions

2.8k answers

0 comments

76 users

Welcome to MCQ Village Q&A, where you can ask questions and receive answers from other members of the community.
...