Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the code to get the the following output: #include // declare row and column size const int ROW_SIZE = 5; const int COLUMN_SIZE =
Modify the code to get the the following output:
#include
// declare row and column size
const int ROW_SIZE = 5;
const int COLUMN_SIZE = 4;
int main()
{
// declare sales arrays
int sales[ROW_SIZE][COLUMN_SIZE];
// Using nested loop to store values in a 2d array
for (int r = 0; r
{
for (int c = 0; c
{
printf("Enter sales [%d][%d]: ", r, c);
scanf("%d", &sales[r][c]);
}
}
// one dimensional array to store the row Average
double rowAvg[COLUMN_SIZE];
// finding the row sum
for (int r = 0; r
// Reset the sum
double sum = 0;
for (int c = 0; c
// Add the element
sum = sum + sales[r][c];
}
rowAvg[r] = sum / COLUMN_SIZE;
}
// one dimensional array to store the column Average
double columnAvg[ROW_SIZE];
// finding the row sum
for (int c = 0; c
double sum = 0; // Reset the sum
for (int r = 0; r
// Add the element
sum = sum + sales[r][c];
}
// get column average
columnAvg[c] = sum/ ROW_SIZE;
}
printf(" Entered receipt table for one-month: ");
printf("\tS01\t\tS02\t\tS03\t\tS04\t\tAverage ");
// Using nested loop to display vlues of a 2d array
for (int i = 0; i
{
printf("P10%d", (i+1));
for (int j = 0; j
{
printf("\t%d\t", sales[i][j]);
}
printf("\t%.2f", rowAvg[i]);
printf(" ");
}
// Print column Average
printf("Average");
for (int c = 0; c
{
printf("\t%.2f\t", columnAvg[c]);
}
// Find high sales person
int highSalesPerson = 0;
for (int c = 0; c
Finally this one month sales will be categorized. For this, the mode calculation will be made and the category will be determined according to the mode table. You have to search and apply calculation of mode if you have no idea about mode calculation. MODE TABLE MODE VALUE 1-10 11-20 21-30 CATEGORY BAD GOOD EXCELLENT Entered receipt table for one-month: S01 SO2 SO3 S04 Average P101 27 16 9 8 15.00 P102 23 20 14 7 16.00 P103 18 17 15 12 15.50 P104 14 15 14 18 15.25 P105 20 16 19 25 20.00 Avg 20.40 16.80 14.20 14.00 The salesperson of the month is with 20.4 is s01 The product of the month is with 20.0 is P105 Mode 14 -> GOOD SALES if(columnAvg[c] > columnAvg[highSalesPerson]){
highSalesPerson = c;
}
}
// find high product
int highProduct = 0;
for (int r = 0; r
if(rowAvg[r] > rowAvg[highProduct]){
highProduct = r;
}
}
// Print the results
printf(" The salesperson of the month is with %.2f is S0%d", columnAvg[highSalesPerson], highSalesPerson+1);
printf(" The product of the month is with %.2f is P10%d", rowAvg[highProduct], highProduct+1);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started