blob: 8806617d2069bb2a2ba3b2ccb4a54ca1df0ed07a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
}
|