Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program of minimum cost problem

Posted By: Reginheraht Fischer     Category: C Programming     Views: 3885

Write a program of minimum cost problem.

Code for Program of minimum cost problem in C Programming

 main()                                                          
   {                                                               
       float p, cost, p1, cost1;                               
                                                               
       for (p = 0; p <= 10; p = p + 0.1)                           
       {                                                           
           cost = 40 - 8 * p + p * p;                              
           if(p == 0)                                              
           {                                                       
              cost1 = cost;                                        
              continue;                                            
           }                                                       
           if (cost >= cost1)                                      
              break;                                               
           cost1 = cost;                                           
           p1 = p;                                                 
       }                                                           
       p = (p + p1)/2.0;                                           
       cost = 40 - 8 * p + p * p;                                  
       printf("\nMINIMUM COST = %.2f  AT  p = %.1f\n",         
                cost, p);                                      
   }                                                               
                                                            
Output                                                      
                                                        
   MINIMUM COST = 24.00  AT  p = 4.0                           
  
Share: 


Didn't find what you were looking for? Find more on Program of minimum cost problem Or get search suggestion and latest updates.

Reginheraht Fischer
Reginheraht Fischer author of Program of minimum cost problem is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
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!