# C program for production and sales analysis

In this tutorial, we are going to write a C Program for production and sales analysis in C Programming with practical program code and step-by-step full complete explanation.

## C Program for production and sales analysis.

```
#include<stdio.h>
#include<conio.h>

void main()
{
int M[5][6], S[5][6], C[6], Mvalue[5][6], Svalue[5][6], Mweek[5], Sweek[5], Mproduct[6], Sproduct[6], Mtotal, Stotal, i, j, number;

printf("Enter products manufactured week wise");
printf("M11, M12,-,M21,M22,-etc");

for(i=1;i<=4;i++)
for(j=1;j<=5;j++)
scanf("%d",&M[i][j]);

printf("Enter products sold week wise");
printf("S11,S12,-,S21,S22,-etc");

for(i=1;i<=4;i++)
for(j=1;j<=5;j++)
scanf("%d",&S[i][j]);

printf("Enter the cost of each product");

for(j=1;j<=5;j++)
scanf("%d",&C[j]);

for(i=1;i<=4;i++)
for(j=1;j<=5;j++)
{
Mvalue[i][j]=M[i][j]*C[j];
Svalue[i][j]=S[i][j]*C[j];
}
for(i=1;i<=4;i++)
{
Mweek[i]=0;
Sweek[i]=0;
for(j=1;j<5;j++)
{
Mweek[i] += Mvalue[i][j];
Sweek[i]+= Svalue[i][j];
}
}
for(j=1;j<=5;j++)
{
Mproduct[j]=0;
Sproduct[j]=0;

for(i=1;i<=4;i++)
{
Mproduct[i] += Mvalue[i][j];
Sproduct[i] += Svalue[i][j];
}
}

Mtotal=Stotal=0;

for(i=1;i<=4;i++)
{
Mtotal+=Mweek[i];
Stotal+=Sweek[i];
}

printf("\n\n");
printf("Following is the list of things you can\n");
printf("request for enter appropriate item number and press RETURN key\n");
printf("1. Value matrices of production & sales\n");
printf("2. Total value of weekly production & sales\n");
printf("3. Product-wise montly value of production & sales\n");
printf("4. Grand total value of production & sales\n");
printf("5. Exit\n");

number=0;

while(1)
{
scanf("%d", &number);
printf("\n");

if(number==5)
{
printf("GOOD BYE");
break;
}

switch(number)
{
case 1:
printf("VALUE MATRIX OF PRODUCTION\n");
for(i=1;i<=4;i++)
{
printf("Week (%d)",i);
for(j=1;j<=5;j++)
printf("%7d",Mvalue[i][j]);
printf("\n");
}
printf("VALUE MATRIX OF SALES\n");
for(i=1;i<=4;i++)
{
printf("Week(%d)",i);
for(j=1;j<=5;j++)
printf("%7d",Svalue[i][j]);
printf("\n");
}
break;

case 2:
printf("TOTAL WEEKLY PRODUCTION & SALES\n");
printf("             PRODUCTION SALES\n");
printf("            ---------- ----     \n");

for(i=1;i<=4;i++)
{
printf("Week(%d)",i);
printf("%7d%7d",Mweek[i],Sweek[i]);
}
break;

case 3:
printf("PRODUCT WISE TOTAL PRODUCTION & SALES\n");
printf("             PRODUCTION SALES\n");
printf("              ------------   ------  \n");

for(j=1;j<=5;j++)
{
printf("Product(%d)\n",j);
printf("%7d%7d",Mproduct[j],Sproduct[j]);
}
break;

case 4:
printf("GRAND TOTAL OF PRODUCTION SALES\n");
printf("Total production=%d\n",Mtotal);
break;

default:
printf("Wrong choice, select gain\n");
break;
}
}
printf("Exit from the program");
}
```

### Output

```
Enter products manufactured week wise
M11,M12,----M21,M22,----etc
11  15      12  14      13
13  13      14  15      12
12  16      10  15      14
14  11      15  13      12

Enter products sold week wise
S11, S12, --- S21, S22, --- etc
10   13       9    12    11
12   10       12   14    10
11   14       10   14    12
12   10       13   11    10

Enter cost of each product
10 20 30 15 25

Following is the list of things you can request for enter appropriate item nuber and press RETURN key
1. Value matrices of production & sales
2. Total value of weekly production & sales
3. Product-wise montly value of production & sales
4. Grand total value of production & sales
5. Exit

VALUE MATRIX OF PRODUCTION
Week(1) 110 300 360 210 325
Week(2) 130 260 420 225 300
Week(3) 120 320 300 225 350
Week(4) 140 220 450 210 300

VALUE MATRIX OF SALES
Week(1) 100 260 270 180 275
Week(2) 120 200 360 210 250
Week(3) 110 280 300 210 300
Week(4) 120 200 390 165 250

TOTAL WEEKLY PRODUCTION & SALES

PRODUCTION     SALES
----------    -------
Week(1)  1305          1085
Week(2)  1335          1140
Week(3)  1305          1200
Week(4)  1315          1125

PRODUCT WISE TOTAL PRODUCTION & SALE
PRODUCTION    SALES
----------    -----
Product(1)    500         450
Product(2)    1100        450
Product(3)    1530        450
Product(4)    855         450
Product(5)    1275        1075