99 034
Assignments Done
98.9%
Successfully Done
In May 2021

# Answer to Question #46037 in C for Blessing

Question #46037
Write C a program that accepts sales made by 5 sales reps for the 4 months that they have been selling the company's products. The program should then find the total sales for 4 months, total sales for each sales rep, and total sales per month. The highest and lowest sales for each sales rep and for each month.
1
2014-09-11T07:17:01-0400
#include <stdio.h>#include <stdlib.h>//main methodint main(){   //sales Reps   int salesReps[5][4];   //program  accepts sales made by 5 sales reps for the 4 months that they have been selling the company's products   for(int i=0;i<5;i++){      for(int j=0;j<4;j++){         //prompt user to enter sales         printf("Enter sales made for company %d for moth %d: ",(i+1),(j+1));         scanf("%d",&salesReps[i][j]);      }   }   //The program should then find the total sales for 4 months   int totalSale=0;   for(int i=0;i<5;i++){      for(int j=0;j<4;j++){         //calculate total Sale         totalSale+=salesReps[i][j];      }   }   printf("\n\nThe total sales for 4 months is: %d\n",totalSale);   printf("\n\n");//new lines   //calculate total sales for each sales rep   for(int i=0;i<5;i++){      int totalSalesForEachSaleRep=0;      for(int j=0;j<4;j++){         totalSalesForEachSaleRep+=salesReps[i][j];         }      //show result      printf("The total sales for company %d is: %d\n",(i+1),totalSalesForEachSaleRep);   }   printf("\n\n");//new lines   //calculate total sales per month   for(int i=0;i<4;i++){      int totalSalesPerMonth=0;      for(int j=0;j<5;j++){         totalSalesPerMonth+=salesReps[j][i];         }      //show result      printf("The total sales for month %d is: %d\n",(i+1),totalSalesPerMonth);   }   printf("\n\n");//new lines   //The highest sales for each sales rep   for(int i=0;i<5;i++){      int highestSalesforEachSalesRep=salesReps[i][0];      for(int j=0;j<4;j++){         if(highestSalesforEachSalesRep<salesReps[i][j]){             highestSalesforEachSalesRep=salesReps[i][j];         }      }      //show result      printf("The highest sales for company %d is: %d\n",(i+1),highestSalesforEachSalesRep);   }   printf("\n\n");//new lines   //The lowest sales for each sales rep   for(int i=0;i<5;i++){      int lowestSalesforEachSalesRep=salesReps[i][0];      for(int j=0;j<4;j++){         if(lowestSalesforEachSalesRep>salesReps[i][j]){             lowestSalesforEachSalesRep=salesReps[i][j];         }      }      //show result      printf("The lowest sales for company %d is: %d\n",(i+1),lowestSalesforEachSalesRep);   }   printf("\n\n");//new lines   //The highest sales for each month   for(int i=0;i<4;i++){      int highestSalesforEachMonth=salesReps[0][i];      for(int j=0;j<5;j++){         if(highestSalesforEachMonth<salesReps[j][i]){            highestSalesforEachMonth=salesReps[j][i];         }      }      //show result      printf("The highes sale for month %d is: %d\n",(i+1),highestSalesforEachMonth);   }   printf("\n\n");//new lines   //The lowest sales for each month   for(int i=0;i<4;i++){      int lowestSalesforEachMonth=salesReps[0][i];      for(int j=0;j<5;j++){         if(lowestSalesforEachMonth>salesReps[j][i]){            lowestSalesforEachMonth=salesReps[j][i];         }      }      //show result      printf("The lowest sale for month %d is: %d\n",(i+1),lowestSalesforEachMonth);   }   //delay   system("pause");   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!