Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

Program for production and sales analysis

Posted By: Abel Fischer     Category: C Programming     Views: 5146

Write a program for production and sales analysis.

Code for Program for production and sales analysis in C Programming

 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;                         
                                                               
   /*      Input data         */
printf (" Enter products manufactured week_wise \n"); printf (" M11,M12,----, M21,M22,---- etc\n"); for(i=1; i<=4; i++) for(j=1;j<=5; j++) scanf("%d",&M[i][j]); printf (" Enter products sold week_wise\n"); printf (" S11,S12,----, S21,S22,---- etc\n"); for(i=1; i<=4; i++) for(j=1; j<=5; j++) scanf("%d", &S[i][j]); printf(" Enter cost of each product\n"); for(j=1; j <=5; j++) scanf("%d",&C[j]); /* Value matrices of production and sales */
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]; } /* Total value of weekly production and sales */
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]; } } /* Monthly value of product_wise production and sales */
for(j=1; j<=5; j++) { Mproduct[j] = 0 ; Sproduct[j] = 0 ; for(i=1; i<=4; i++) { Mproduct[j] += Mvalue[i][j]; Sproduct[j] += Svalue[i][j]; } } /* Grand total of production and sales values */
Mtotal = Stotal = 0; for(i=1; i<=4; i++) { Mtotal += Mweek[i]; Stotal += Sweek[i]; } /***********************************************
Selection and printing of information required
***********************************************/
printf("\n\n"); printf(" Following is the list of things you can\n"); printf(" request for. Enter appropriate item number\n"); printf(" and press RETURN Key\n\n"); printf(" 1.Value matrices of production & sales\n"); printf(" 2.Total value of weekly production & sales\n"); printf(" 3.Product_wise monthly value of production &"); printf(" sales\n"); printf(" 4.Grand total value of production & sales\n"); printf(" 5.Exit\n"); number = 0; while(1) { /* Beginning of while loop */
printf("\n\n ENTER YOUR CHOICE:"); scanf("%d",&number); printf("\n"); if(number == 5) { printf(" G O O D B Y E\n\n"); break; } switch(number) { /* Beginning of switch */
/* V A L U E M A T R I C E S */
case 1: printf(" VALUE MATRIX OF PRODUCTION\n\n"); for(i=1; i<=4; i++) { printf(" Week(%d)\t",i); for(j=1; j <=5; j++) printf("%7d", Mvalue[i][j]); printf("\n"); } printf("\n VALUE MATRIX OF SALES\n\n"); for(i=1; i <=4; i++) { printf(" Week(%d)\t",i); for(j=1; j <=5; j++) printf("%7d", Svalue[i][j]); printf("\n"); } break; /* W E E K L Y A N A L Y S I S */
case 2: printf(" TOTAL WEEKLY PRODUCTION & SALES\n\n"); printf(" PRODUCTION SALES\n"); printf(" ---------- -----\n"); for(i=1; i <=4; i++) { printf(" Week(%d)\t", i); printf("%7d\t%7d\n", Mweek[i], Sweek[i]); } break; /* P R O D U C T W I S E A N A L Y S I S */
case 3: printf(" PRODUCT_WISE TOTAL PRODUCTION &"); printf(" SALES\n\n"); printf(" PRODUCTION SALES\n"); printf(" ---------- -----\n"); for(j=1; j <=5; j++) { printf(" Product(%d)\t", j); printf("%7d\t%7d\n",Mproduct[j],Sproduct[j]); } break; /* G R A N D T O T A L S */
case 4: printf(" GRAND TOTAL OF PRODUCTION & SALES\n"); printf("\n Total production = %d\n", Mtotal); printf(" Total sales = %d\n", Stotal); break; /* D E F A U L T */
default : printf(" Wrong choice, select again\n\n"); break; } /* End of switch */
} /* End of while loop */
printf(" Exit from the program\n\n"); } /* End of main */
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 number and press RETURN key 1.Value matrices of production & sales 2.Total value of weekly production & sales 3.Product_wise monthly value of production & sales 4.Grand total value of production & sales 5.Exit ENTER YOUR CHOICE:1 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 185 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 ENTER YOUR CHOICE:2 TOTAL WEEKLY PRODUCTION & SALES PRODUCTION SALES ---------- ----- Week(1) 1305 1085 Week(2) 1335 1140 Week(3) 1315 1200 Week(4) 1305 1125 ENTER YOUR CHOICE:3 PRODUCT_WISE TOTAL PRODUCTION & SALES PRODUCTION SALES ---------- ----- Product(1) 500 450 Product(2) 1100 940 Product(3) 1530 1320 Product(4) 855 765 Product(5) 1275 1075 ENTER YOUR CHOICE:4 GRAND TOTAL OF PRODUCTION & SALES Total production = 5260 Total sales = 4550 ENTER YOUR CHOICE:5 G O O D B Y E Exit from the program
  
Share: 


Didn't find what you were looking for? Find more on Program for production and sales analysis Or get search suggestion and latest updates.

Abel Fischer
Abel Fischer author of Program for production and sales analysis is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!