c programing sohe he following problem A company has four a


c programing

sohe he following problem. A company has four a 2-di imensionalamay who sell five differm prod tahle their last week\'s sales Write a prngram than read allthis information and summarizes the total sales by salesperson and by product. Print the results in tabubur samaa and erosi total each rou to get the total sales ofeach person lotal each coluns get the sakes by each product for last week. Y last week tabular printout hould include heie enors the right orte totaled rows and to the bottom the totaled columns. 100 100 120 80 Product 2 Product 3 Product 4 Predact 5 Sum 210 30 Salesperson 4 30 250 Product Sum 300

Solution

/* Cprogramme */

// C program to displauy sales statistics using 2 dimentional array.
#include <stdio.h>

const int nosp = 4;           //number of salespersonns
const int nop = 5;           //number of products

int main()
{
   int sum=0,productsum=0;
    int sales_stats[nosp][nop];
    int i,j;
    // Loop for reading data for each salesperson,prodct wise
    for (i = 0; i < nosp; ++i) {
        for(j = 0; j < nop; ++j) {
            printf(\"Enter Salesperson %d Sales of Product %d: \", i+1, j+1);   //prompt for input data
            scanf(\"%d\", &sales_stats[i][j]);                                   //read for input data
        }
    }
   // Display Output as criteria format
    printf(\"\ Summery of Sales: \ \ \");                                      
    printf(\"\\t\\tProduct1\\tProduct2\\tProduct3\\tProduct4\\tProduct5\\tSum\ \");
    for (i = 0; i < nosp; ++i) {
       printf(\"\ Salesperson%d\", i+1);
       sum=0;
        for(j = 0; j < nop; ++j)
        {
          
              sum=sum+sales_stats[i][j];               //summation of row wise each sales person sale of all products
             printf(\"\\t%d\\t\", sales_stats[i][j]);           //dispaly row wise each sales person sale of all products
        }
        printf(\"%d\\t\",sum);                               //display sum of all products of each sales person
    }
    //loop to dispaly product sum
    printf(\"ProductSum\");
    for (i = 0; i < nop; ++i) {
  
       productsum=0;
        for(j = 0; j < nosp; ++j)
        {
          
              productsum=productsum+sales_stats[j][i];   //summation of column wise each product sale of all salespersons
         
        }
          printf(\"\\t%d\\t\", productsum);                   //display productsum
      
    }
    return 0;
}

Sample Output :

Enter Salesperson 1 Sales of Product 1: 100
Enter Salesperson 1 Sales of Product 2: 120
Enter Salesperson 1 Sales of Product 3: 210
Enter Salesperson 1 Sales of Product 4: 50
Enter Salesperson 1 Sales of Product 5: 15
Enter Salesperson 2 Sales of Product 1: 120
Enter Salesperson 2 Sales of Product 2: 40
Enter Salesperson 2 Sales of Product 3: 30
Enter Salesperson 2 Sales of Product 4: 50
Enter Salesperson 2 Sales of Product 5: 50
Enter Salesperson 3 Sales of Product 1: 50
Enter Salesperson 3 Sales of Product 2: 100
Enter Salesperson 3 Sales of Product 3: 100
Enter Salesperson 3 Sales of Product 4: 120
Enter Salesperson 3 Sales of Product 5: 80
Enter Salesperson 4 Sales of Product 1: 30
Enter Salesperson 4 Sales of Product 2: 250
Enter Salesperson 4 Sales of Product 3: 75
Enter Salesperson 4 Sales of Product 4: 45
Enter Salesperson 4 Sales of Product 5: 20

Summery of Sales:

                Product1        Product2        Product3        Product4 Product5        Sum

Salesperson1    100             120             210            50                15           495
Salesperson2    120             40              30                  50                 50     290
Salesperson3    50              100             100                120                80     450
Salesperson4    30              250             75                  45                  20           420    

ProductSum      300             510             415               265             165
--------------------------------

 c programing sohe he following problem. A company has four a 2-di imensionalamay who sell five differm prod tahle their last week\'s sales Write a prngram than
 c programing sohe he following problem. A company has four a 2-di imensionalamay who sell five differm prod tahle their last week\'s sales Write a prngram than

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site