diff options
Diffstat (limited to 'force2.c')
| -rw-r--r-- | force2.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/force2.c b/force2.c new file mode 100644 index 0000000..8806617 --- /dev/null +++ b/force2.c @@ -0,0 +1,25 @@ +/*File : force2.c Calculate the peicewise time force. The formulas depend on wether time t is 0<=t<=3 or t>0*/ +#include <stdio.h> +#define M 3 + +int main() +{ + + double p, t; + printf("Please input time in seconds: "); + scanf("%lf",&t); + if(0<=t && t<=M){ + p = 20; + printf("Force p = %f (N)\n",p); + } + else if(t>3) + { + p = 4*(t+2); + printf("Force p = %f (N)\n",p); + } + else + { + printf("Invalid input, time is never negitive\n"); + } + return 0; +} |
