summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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