paradox64ce

hare tortoise.c

Jan 7th, 2020
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     float d,x,y,s_hare=1.4,s_tort=0.9;
  6.     printf("Enter D in meter = ");
  7.     scanf("%f",&d);
  8.     printf("Enter X in minute = ");
  9.     scanf("%f",&x);
  10.     printf("Enter Y in minute = ");
  11.     scanf("%f",&y);
  12.     //do something
  13.     float t_hare=y+d/s_hare;
  14.     float t_tort=d/s_tort;
  15.  
  16.     printf("Time taken by Tortoise: %f minutes\n",t_tort);
  17.     printf("Time taken by Hare: %f minutes\n",t_hare);
  18.  
  19.         float w_dist=0.0,t;
  20.     if(t_hare>t_tort)
  21.         {
  22.          t=t_hare-t_tort;
  23.          w_dist=t*s_hare;
  24.         }
  25.         else{
  26.             t=t_tort-t_hare;
  27.             w_dist=t*s_tort;
  28.          }
  29.     printf("Winning distance margin: %f\n",w_dist);
  30.         printf("Done\n");
  31.         return 0;
  32.  
  33.  
  34. }
RAW Paste Data