Search This Blog

Loading...

Inventory Report in C Programming

#define ITEMS 4                                            
                                                              
   main()                                                     
   {  /* BEGIN */
int i, quantity[5];                                     
      float rate[5], value, total_value;                      
      char code[5][5];                                        
      /*   READING VALUES   */
                                
      i = 1;                                                  
      while ( i <= ITEMS)                                     
      {                                                       
printf("Enter code, quantity, and rate:");
scanf("%s %d %f", code[i], &quantity[i],&rate[i]); 
        i++;                                                
      }                                                       
   /*.......Printing of Table and Column Headings.......*/
    
      printf("\n\n");                                         
      printf("             INVENTORY REPORT          \n");     
      printf("-------------------------------------------\n");
      printf(" Code      Quantity   Rate      Value      \n");   
      printf("-------------------------------------------\n");
   /*.......Preparation of Inventory Position..........*/
     
      total_value = 0;                                        
      i = 1;                                                  
      while ( i <= ITEMS)                                     
      {                                                       
value = quantity[i] * rate[i];                       
printf("%5s %10d %10.2f %e\n",code[i],quantity[i], 
        rate[i],value);                              
total_value += value;                                
i++;                                                
      }                                                       
   /*.......Printing of End of Table..................*/
      
      printf("---------------------------------------------\n");
      printf("                Total Value = %e\n",total_value);
      printf("---------------------------------------------\n");
                                                              
   }  /* END */

                                                                                           
Output :                                                    
   Enter code, quantity, and rate:F105  275  575.00           
   Enter code, quantity, and rate:H220  107   99.95           
   Enter code, quantity, and rate:I019  321  215.50           
   Enter code, quantity, and rate:M315   89  725.00           
                                                              
                INVENTORY REPORT                              
  -----------------------------------------------               
    Code      Quantity   Rate      Value                      
  -----------------------------------------------
    F105        275     575.00   1.581250e+005                
    H220        107      99.95   1.069465e+004                
    I019        321     215.50   6.917550e+004                
    M315         89     725.00   6.452500e+004                
  -----------------------------------------------                
                   Total Value = 3.025202e+005                
  -----------------------------------------------

No comments:

Post a Comment