C Program to Calculate Loss Percentage

Let’s have a glance at how to find the loss percentage by using the C programming language.

How to calculate the loss percentage?

We can use the following formulae to calculate the loss percentage.

Loss = Cost Amount -  Sold Amount
Loss Percentage = (Loss * 100/Cost Amount)

C Program to Calculate Loss Percentage

#include<stdio.h>                                                             
                                                                                                                                                                                                                                                                         
void main()                                                                     
{                                                                               
  double cp, sp, loss, loss_per;                                            
  printf("Enter cost amount: ");                                                
  scanf("%lf", &cp);                                                          
  printf("Enter sold amount: ");                                                
  scanf("%lf", &sp);                                                          
                                                                                
  loss = cp- sp;                                                           
  loss_per = ((loss *100)/cp);                                                
  printf("Loss Percentage: %lf\n", loss_per);                                   
}

Output

Enter cost amount: 30                                                                                                         
Enter sold amount: 10                                                                                                         
Loss Percentage: 66.666667

Leave a Comment

Your email address will not be published. Required fields are marked *