B
Bill Cunningham
I have this code I hope it explains itself. I correctly wrote a root
program for simple radicals such as 2 to the 5th power. But I wanted to
expland on that to include a radicand that is 5 cubed for example, raised to
the 5th power. I received this compiler warning too. Am I correct in my
surmise that there is a loop error somewhere?
r.c: In function `main':
r.c:6: warning: comparison between pointer and integer
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc < 3 || argv > 4) {
fputs("root usage error\n base power(s)\n", stderr);
exit(EXIT_FAILURE);
}
double base, power, powers;
base = strtod(argv[1], NULL);
power = strtod(argv[2], NULL);
if (argv[4] == NULL) {
printf("%.2f\n", base / power);
exit(0);
if (argv[4] != NULL) {
powers = strtod(argv[4], NULL);
printf("%.2f\n", (base * power) / powers);
exit(0);
}
}
return 0;
}
This is pretty complex for me.
Bill
program for simple radicals such as 2 to the 5th power. But I wanted to
expland on that to include a radicand that is 5 cubed for example, raised to
the 5th power. I received this compiler warning too. Am I correct in my
surmise that there is a loop error somewhere?
r.c: In function `main':
r.c:6: warning: comparison between pointer and integer
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc < 3 || argv > 4) {
fputs("root usage error\n base power(s)\n", stderr);
exit(EXIT_FAILURE);
}
double base, power, powers;
base = strtod(argv[1], NULL);
power = strtod(argv[2], NULL);
if (argv[4] == NULL) {
printf("%.2f\n", base / power);
exit(0);
if (argv[4] != NULL) {
powers = strtod(argv[4], NULL);
printf("%.2f\n", (base * power) / powers);
exit(0);
}
}
return 0;
}
This is pretty complex for me.
Bill