Asked by Blessing
Write a C 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.
#include <stdio.h>
int main ()
{
int sales[5][4];
int i,j,sum,sum2,lowest,highest;
printf("Please enter a number:");
printf("\n");
for (i=0;i<5;++i)
{
for(j=0;j<4;++j)
{
scanf("%d",&sales[i][j]);
}
}
printf("\n\tMonth 1\tMonth 2\tMonth 3\tMonth 4\tTotal");
printf("\n");
for(i=0;i<5;++i)
{
sum=0;
for(j=0;j<4;++j)
{
sum=sum+sales[i][j];
printf("\t%3d",sales[i][j]);
}
printf("\t%3d",sum);
printf("\n");
}
printf("*************************************************************\n");
printf("\nTotal");
for(i=0;i<5;++i)
{
sum2=0;
for(j=0;j<4;++j)
{
sum2=sum2+sales[j][i];
printf("\t%3d",sum2);
}
printf("\n");
{
lowest=sales[0][0];
for(i=0;i<5;i++)
{
for(j=0;j<1;++j)
if(sales[i][j]<lowest)
lowest=sales[i][j];
}
printf("\nLowest = $%d",lowest);
lowest=sales[1][1];
for(i=0;i<5;i++)
{
for(j=1;j<2;++j)
if(sales[i][j]<lowest)
lowest=sales[i][j];
}
printf("\t$%d",lowest);
lowest=sales[2][2];
for(i=0;i<5;i++)
{
for(j=2;j<3;++j)
if(sales[i][j]<lowest)
lowest=sales[i][j];
}
printf("\t$%d",lowest);
lowest=sales[3][3];
for(i=0;i<5;i++)
{
for(j=3;j<4;++j)
if(sales[i][j]<lowest)
lowest=sales[i][j];
}
printf("\t$%d",lowest);
}
getch();
}
}
Answers
                    Answered by
            Anonymous
            
    Without using array
    
                                                    There are no AI answers yet. The ability to request AI answers is coming soon!
                                            
                Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.