diff options
author | sinanmohd <sinan@firemail.cc> | 2023-05-15 08:15:11 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-05-15 08:15:11 +0530 |
commit | 95b4f909ac709c098fb0ff59d3638826baaae0c0 (patch) | |
tree | 59d5112069d8de953ed43409e8283128f2e359f0 /7.9.c | |
parent | 29af05de1994802e315de989316f3d854a146624 (diff) |
7.9: initial commit
Diffstat (limited to '7.9.c')
-rw-r--r-- | 7.9.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#include <stdio.h> + +/* 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; +} |