From 6b4e1641366f51e27eae78a2506b4b66d3e9cd4c Mon Sep 17 00:00:00 2001 From: Hyder Hadi Date: Tue, 31 Mar 2026 13:37:32 +0300 Subject: Simple C exercises that i solved :D --- simple-C-programs/cc4e_ch5_exercise.c | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 simple-C-programs/cc4e_ch5_exercise.c (limited to 'simple-C-programs/cc4e_ch5_exercise.c') 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 + +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 -- cgit v1.2.3