summaryrefslogtreecommitdiffstats
path: root/2/10.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-01 23:14:53 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-01 23:14:53 +0800
commitec38e6e0c38d3653b80701d5fc0df2ce92e59742 (patch)
tree4bce94f313723a963bbc2e7f3b6549bc57ca2d51 /2/10.c
parentc800a6727d58641f97db0f24a6e3ad1076a4eec7 (diff)
downloadk&r-exercises-ec38e6e0c38d3653b80701d5fc0df2ce92e59742.tar.gz
2.10
Diffstat (limited to '2/10.c')
-rw-r--r--2/10.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/2/10.c b/2/10.c
new file mode 100644
index 0000000..8e23af7
--- /dev/null
+++ b/2/10.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+/* converts ASCII c to lowercase */
+int lower(int c) { return c >= 'A' && c <= 'Z' ? c + 'a' - 'A' : c; }
+
+int main(int argc, char *argv[]) {
+ int c;
+
+ for (;;) {
+ printf("Enter char to convert to lowercase.\n");
+ c = getchar();
+ if (c == EOF)
+ break;
+ else
+ printf("%c\n", lower(c));
+
+ getchar();
+ }
+
+ return 0;
+} \ No newline at end of file