fork download
  1. #include<stdio.h>
  2.  
  3. int main() {
  4.  
  5. int tickets;
  6. char student;
  7. float total, discount = 0;
  8.  
  9. printf("Enter the number of tickets: ");
  10. scanf ("%d", &tickets);
  11.  
  12. printf("Are you a student? y/n: ");
  13. scanf("%d", &student);
  14.  
  15. total = tickets * 100;
  16.  
  17. if(tickets > 15) discount += 0.20;
  18. if(student == 'y' || student == 'Y')
  19. discount += 0.05; // extra 5%
  20.  
  21. total = total * (1 - discount);
  22.  
  23. printf("Tickets:PHP %.2f\n", total);
  24.  
  25. return 0;
  26.  
  27.  
  28. }
Success #stdin #stdout 0.01s 5288KB
stdin
45
stdout
Enter the number of tickets: Are you a student? y/n: Tickets:PHP 3600.00