|
|
1.1 root 1: #include <math.h>
2: #include <stdio.h>
3: #define display(x) dodisplay((double)(x), #x)
4:
5: dodisplay(value, name)
6: double value; char *name;
7: {
8: if (errno)
9: perror(name);
10: else
11: printf("%10g %s\n", value, name);
12: errno = 0;
13: }
14:
15: main()
16: {
17: extern char *gets();
18: double x;
19: char string[64];
20:
21: for (;;) {
22: printf("Enter number: ");
23: if (gets(string) == NULL)
24: break;
25: x = atof(string);
26:
27: display(x);
28: display(ceil(x));
29: display(floor(x));
30: display(fabs(x));
31: display(sqrt(x));
32: }
33: putchar('\n');
34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.