From 39f7a17cc1e1b93d3ee0c85548131a96f7fb7c19 Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 29 Sep 2021 19:14:47 +0800 Subject: [PATCH] add 4-xpr1.c --- pset2/4-xpr1.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pset2/4-xpr1.c diff --git a/pset2/4-xpr1.c b/pset2/4-xpr1.c new file mode 100644 index 0000000..04c130f --- /dev/null +++ b/pset2/4-xpr1.c @@ -0,0 +1,15 @@ +#include +#include + +int main(void) { + + // initialize variables + double a, b, c, d; + scanf("%lf %lf %lf %lf", &a, &b, &c, &d); + + // trinary expression magic. same as above + (b * c - d < 1e-6 && b * c - d > -1e-6) ? printf("error") + : printf("%.1lf", a / (b * c - d)); + + return 0; +}