fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num,a,numr,sp,cp,b;
  5. float pr,profit;
  6. printf("Enter the number of dozens of toys purchased\n");
  7. scanf("%d",&num);
  8. printf("Enter the price per dozen\n");
  9. scanf("%d",&a);
  10. printf("Enter the selling price of 1 toy\n");
  11. scanf("%d",&b);
  12. cp=(a*num);
  13.  
  14. sp=(b*12*num);
  15. numr=(float)sp-cp;
  16. pr=((float)numr/cp);
  17. profit=pr*100;
  18. if(profit<0)
  19. {
  20. printf("Price should not be negative\n");
  21. }
  22. else
  23. printf("Sanjay's profit percentage is %.2f",profit);
  24. return 0;
  25. }
Success #stdin #stdout 0s 9416KB
stdin
20
375
33
stdout
Enter the number of dozens of toys purchased
Enter the price per dozen
Enter the selling price of 1 toy
Sanjay's profit percentage is 5.60