fork(2) download
  1. #include<stdio.h>
  2. int main(){
  3. int start_time;
  4. int end_time;
  5. int duration;
  6. printf("Enter the start_time:\n");
  7. scanf("%d",&start_time);
  8. printf("Enter the end_time:\n");
  9. scanf("%d",&end_time);
  10. if(start_time<end_time){
  11.  
  12. duration=end_time-start_time;
  13. }
  14. else if(start_time>end_time){
  15. duration=(24-start_time)+end_time;
  16. }
  17. else{
  18. duration=24;
  19. }
  20. printf("THE GAME LASTED %d HOUR(S)" ,duration);
  21. return 0;
  22. }
Success #stdin #stdout 0s 5316KB
stdin
10
14
stdout
Enter the start_time:
Enter the end_time:
THE GAME LASTED 4 HOUR(S)