P018.c (729B)
1 /* WAP to input the cost price and selling price and 2 calculate profit, profit percentage, loss percentage or 3 display the manage nither profit nor loss. */ 4 5 #include <stdio.h> 6 int main() 7 { 8 double cost, sell, pro, prop, loss, lossp; 9 printf("Enter the cost and selling price : "); 10 scanf("%lf %lf", &cost, &sell); 11 if (sell > cost) 12 { 13 pro = sell - cost; 14 prop = (pro / cost) * 100; 15 printf("Profit : RS %g, Profit Percentage : %g", pro, prop); 16 } 17 else if (sell < cost) 18 { 19 loss = cost - sell; 20 lossp = (loss / cost) * 100; 21 printf("Loss : RS %g, Loss Percentage : %g", loss, lossp); 22 } 23 else 24 printf("Neither loss nor Profit."); 25 return 0; 26 }