From 95b4f909ac709c098fb0ff59d3638826baaae0c0 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Mon, 15 May 2023 08:15:11 +0530 Subject: 7.9: initial commit --- 7.9.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 7.9.c diff --git a/7.9.c b/7.9.c new file mode 100644 index 0000000..642efb1 --- /dev/null +++ b/7.9.c @@ -0,0 +1,23 @@ +#include + +/* saves time (no function overhead) but uses more space + * since the macro is expanded on each call, also + * the argument can be evaluated twice and cause problems + * eg: isupper_m(p++), the soln is isupper(p); p++ */ +#define isupper_m(c) (c >= 'A' && c <= 'Z') ? 1 : 0 + +/* uses more time bus saves on space */ +int isupper_f(char c); + +int main(void) +{ + printf("M: %d, m: %d\n", isupper_m('M'), isupper_m('m')); + printf("F: %d, f: %d\n", isupper_f('F'), isupper_f('f')); + + return 0; +} + +int isupper_f(char c) +{ + return (c >= 'A' && c <= 'Z') ? 1 : 0; +} -- cgit v1.2.3