fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int cp,sp;
  5. float profit,loss;
  6. printf("write cost price \n write selling price\n");
  7. scanf("%d , %d" , &cp, &sp);
  8. if(sp>cp){
  9. printf("you are in profit\n");
  10. profit=((sp-cp)/cp)*100;
  11. printf("you are in profit by %f percentage", profit);
  12. }
  13. else if (cp>sp){
  14. printf("you are in loss\n");
  15. loss=((cp-sp)/cp)*100;
  16. printf("you are in loss by %f percentage", loss);
  17. }
  18. else{
  19. printf("you are neither in loss nor in profit ");
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5276KB
stdin
1566 1500
stdout
write cost price 
 write selling price
you are in profit
you are in profit by 1900.000000 percentage