Projects-based tasks about recursion
- Tested on WSL Ubuntu 20.04 LTS
All of the following files are programs written in C:
Filename | Task | Prototype |
---|---|---|
0-puts_recursion.c | "She locked away a secret, deep inside herself, something she once knew to be true... but chose to forget". Write a function that prints a string, followed by a new line. | Prototype: void _puts_recursion(char *s); FYI: The standard library provides a similar function: puts. Run man puts to learn more. |
1-print_rev_recursion.c | "Why is it so important to dream? Because, in my dreams we are together". Write a function that prints a string in reverse. | Prototype: void _print_rev_recursion(char *s); |
2-strlen_recursion.c | "Dreams feel real while we're in them. It's only when we wake up that we realize something was actually strange". Write a function that returns the length of a string. | Prototype: int _strlen_recursion(char *s); FYI: The standard library provides a similar function: strlen. Run man strlen to learn more. |
3-factorial | "You mustn't be afraid to dream a little bigger, darling". Write a function that returns the factorial of a given number. | Prototype: int factorial(int n); If n is lower than 0, the function should return -1 to indicate an error Factorial of 0 is 1 |
4-pow_recursion.c | "Once an idea has taken hold of the brain it's almost impossible to eradicate". Write a function that returns the value of x raised to the power of y. | Prototype: int _pow_recursion(int x, int y); If y is lower than 0, the function should return -1 FYI: The standard library provides a different function: pow. Run man pow to learn more. |
5-sqrt_recursion.c | "Your subconscious is looking for the dreamer". Write a function that returns the natural square root of a number. | Prototype: int _sqrt_recursion(int n); If n does not have a natural square root, the function should return -1 FYI: The standard library provides a different function: sqrt. Run man sqrt to learn more. |
6-is_prime_number.c | "Inception. Is it possible?". Write a function that returns 1 if the input integer is a prime number, otherwise return 0. | Prototype: int is_prime_number(int n); |
7-is_palindrome.c | "They say we only use a fraction of our brain's true potential. Now that's when we're awake. When we're asleep, we can do almost anything". Write a function that returns 1 if a string is a palindrome and 0 if not. | Prototype: int is_palindrome(char *s); An empty string is a palindrome |
Advanced task 100-wildcmp.c | mandatory tasks |