Computer Science, asked by mdrakibulislam12188, 8 months ago

In a small company there are five salesmen. Each salesman is supposed to sell three products. Write a program using 2D array to print total sales by each item.

Answers

Answered by gamer7854
3

Answer:

pls mark brainliest

Explanation:int sales [5][3], i, j, total = 0;

printf("Enter the data:\n");

for(i=0;i<5;i++)

{

 printf("Enter the sales of 3 items sold by salesman %d: ", i+1);

 for(j=0;j<3;j++)

  scanf("%d", &sales[i][j]);

}

// Print total sales by each salesman

for(i=0;i<5;i++)

{

 total = 0;

 for(j=0;j<3;j++)

 {

  total+=sales[i][j];

 }

 printf("Total Sales By Salesman %d = %d\n", i+1, total);

}

// Total sales of each item

for(i=0;i<3;i++)

{

 total = 0;

 for(j=0;j<5;j++)

 {

  total += sales[j][i];

 }

 printf("Total sales of item %d = %d\n", i+1, total);

}

return 0;

}

Similar questions