aboutsummaryrefslogtreecommitdiff
path: root/simple-C-programs/cc4e_ch5_exercise.c
diff options
context:
space:
mode:
authorHyder Hadi <hyder@hyderhadi.xyz>2026-03-31 13:37:32 +0300
committerHyder Hadi <hyder@hyderhadi.xyz>2026-03-31 13:37:32 +0300
commit6b4e1641366f51e27eae78a2506b4b66d3e9cd4c (patch)
treeb0030b9b9eb4584f3b81a8344f4faa8a759989cd /simple-C-programs/cc4e_ch5_exercise.c
parent30a472f58f204dfbf325b8b389c9f3008aa4c40b (diff)
Simple C exercises that i solved :D
Diffstat (limited to 'simple-C-programs/cc4e_ch5_exercise.c')
-rw-r--r--simple-C-programs/cc4e_ch5_exercise.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/simple-C-programs/cc4e_ch5_exercise.c b/simple-C-programs/cc4e_ch5_exercise.c
new file mode 100644
index 0000000..b3667b7
--- /dev/null
+++ b/simple-C-programs/cc4e_ch5_exercise.c
@@ -0,0 +1,44 @@
+
+#include <stdio.h>
+
+void process(char *line) {
+
+ // first function of the function;
+ printf("\nString: %s\n", line);
+
+ // second function of the function
+ int count = 0;
+ while (line[count] != '\0') {
+ count++;
+ }
+ printf("Count=%d\n", count);
+
+ // third function of the function
+ if (count > 10) {
+ printf("The tenth character is: %c", line[9]);
+ }
+
+ // fourth function of the function
+
+ count = 0;
+ while (line[count] != '\0') {
+ if (line[count] == ' ') {
+ line[count] = '-';
+ }
+ count++;
+ }
+
+ // fifth fucntion of the function
+ printf("\nString: %s\n", line);
+}
+
+int main() {
+
+ char input[1000];
+
+ fgets(input, sizeof(input) - 1, stdin);
+
+ process(input);
+
+ return 0;
+} \ No newline at end of file