B
Bill Cunningham
I have written this little program and I'm sure there's errors in it but
not like I imagined the compiler says EXIT_FAILURE passed to exit is
recognized. WHat's wrong here.
#include <stdio.h>
#include <math.h>
#include <ctype.h>
int main(int argc, char **argv)
{
double ma, ab1, price, res;
int a;
if (argc != 3) {
puts("ma usage error: ma, price");
exit(EXIT_FAILURE);
}
if ((a = isdigit(argv[1])) != 0) {
puts("ma must be pos number");
exit(EXIT_FAILURE);
}
ma = strtod(argv[1], NULL);
price = strtod(argv[2], NULL);
res = (fabs(price) - fabs(ma)) / fabs(ma);
printf("%f.2\n", res);
return 0;
}
This is suppoed to take two args. The first, the number of days in a
moving average. The second the price of a security. This is the formula.
(price-ma)/ma and the result in res can be positive or negative.
Bill
not like I imagined the compiler says EXIT_FAILURE passed to exit is
recognized. WHat's wrong here.
#include <stdio.h>
#include <math.h>
#include <ctype.h>
int main(int argc, char **argv)
{
double ma, ab1, price, res;
int a;
if (argc != 3) {
puts("ma usage error: ma, price");
exit(EXIT_FAILURE);
}
if ((a = isdigit(argv[1])) != 0) {
puts("ma must be pos number");
exit(EXIT_FAILURE);
}
ma = strtod(argv[1], NULL);
price = strtod(argv[2], NULL);
res = (fabs(price) - fabs(ma)) / fabs(ma);
printf("%f.2\n", res);
return 0;
}
This is suppoed to take two args. The first, the number of days in a
moving average. The second the price of a security. This is the formula.
(price-ma)/ma and the result in res can be positive or negative.
Bill