Initial commit

This commit is contained in:
github-classroom[bot] 2025-01-07 06:46:34 +00:00 committed by GitHub
commit 15c381aaae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 828 additions and 0 deletions

36
main_driver.c Normal file
View file

@ -0,0 +1,36 @@
/*----------------------------------------------------------
* HTBLA-Leonding
* ---------------------------------------------------------
* Title: Running recursive and iterative algorithms
* Author: S. Schraml
* ----------------------------------------------------------
*/
#include "sum_of_digits.h"
#include "count_char.h"
#include "reverse_string.h"
#include <stdio.h>
#include <string.h>
int main() {
printf("\n===========================================\n");
printf("Executing recursive and iterative algorithms:\n");
int num = 1234;
printf("Sum of digits of %d is: %d (recursive) / %d (iterative)\n", num,
sum_of_digits_recursive(num), sum_of_digits_iterative(num));
char str[] = "banana";
char target = 'a';
printf("The character '%c' appears %d (recursive) / %d (iterative) times in \"%s\".\n", target,
count_char_recursive(str, target), count_char_iterative(str, target), str);
char str1[] = "hello";
char str2[] = "world";
reverse_string_recursive(str1, 0, strlen(str1) - 1);
reverse_string_iterative(str2, 0, strlen(str2) - 1);
printf("Reversed string: %s (recursive) / %s (iterative)\n", str1, str2);
printf("===========================================\n\n");
return 0;
}