chundoong-lab-ta/SHPC2022/hw1/sqrt.c

20 lines
369 B
C
Raw Normal View History

2022-10-04 21:07:02 +09:00
#include <math.h>
2022-09-19 17:13:21 +09:00
#include <stdio.h>
#include <stdlib.h>
void fallback_print_usage() {
printf("Usage: ./sqrt number\n");
printf("Example: ./sqrt 2\n");
exit(0);
}
2022-10-04 21:07:02 +09:00
void print_sqrt(double number) { printf("%.8lf\n", sqrt(number)); }
2022-09-19 17:13:21 +09:00
2022-10-04 21:07:02 +09:00
int main(int argc, char *argv[]) {
if (argc != 2) {
fallback_print_usage();
}
print_sqrt(atof(argv[1]));
return 0;
2022-09-19 17:13:21 +09:00
}