> For the complete documentation index, see [llms.txt](https://42-guide.gitbook.io/42-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://42-guide.gitbook.io/42-guide/piscine-life/c05.md).

# C05

#### **Overall Explanation of C05**

The document is the subject for the **C 05 module** of the **C Piscine** at **42**. It contains a series of programming exercises designed to test and improve your skills in **C programming**, with a focus on **iterative and recursive functions**, **mathematical operations**, and **problem-solving**.

***

#### **Key Sections of the Document**

1. **Instructions**:
   * The document is the **only reference** you should rely on; avoid trusting rumors.
   * The document may change before submission, so stay updated.
   * Ensure proper file and directory permissions.
   * Follow submission procedures strictly.
   * Exercises will be graded by **peers** and an automated program called **Moulinette**.
   * Moulinette is strict and uses **norminette** to check if your code adheres to the coding standards (the Norm).
   * Exercises are ordered by difficulty, and harder exercises won't be considered if easier ones aren't completed correctly.
   * Using forbidden functions is considered cheating and results in a grade of **-42**.
   * Compilation is done with `-Wall -Wextra -Werror` flags, and if your program doesn't compile, you get a **0**.
   * You can only submit the files specified in the subject; no additional files are allowed.
2. **Exercises**:
   * The document contains **8 exercises**, each focusing on a specific programming concept. The exercises are ordered by difficulty, starting from the easiest and progressing to the most challenging.
   * Each exercise has a **specific goal**, **allowed functions**, and a **prototype** that you must follow.

***

#### **List of Exercises**

1. **Exercise 00: ft\_iterative\_factorial**
   * Create an **iterative function** that calculates the factorial of a given number.
   * Prototype: `int ft_iterative_factorial(int nb);`
   * Invalid arguments should return **0**.
2. **Exercise 01: ft\_recursive\_factorial**
   * Create a **recursive function** that calculates the factorial of a given number.
   * Prototype: `int ft_recursive_factorial(int nb);`
   * Invalid arguments should return **0**.
3. **Exercise 02: ft\_iterative\_power**
   * Create an **iterative function** that calculates the power of a number.
   * Prototype: `int ft_iterative_power(int nb, int power);`
   * A power lower than **0** returns **0**.
4. **Exercise 03: ft\_recursive\_power**
   * Create a **recursive function** that calculates the power of a number.
   * Prototype: `int ft_recursive_power(int nb, int power);`
   * A power lower than **0** returns **0**.
5. **Exercise 04: ft\_fibonacci**
   * Create a **recursive function** that returns the **n-th element** of the Fibonacci sequence.
   * Prototype: `int ft_fibonacci(int index);`
   * Invalid indices (less than **0**) should return **-1**.
6. **Exercise 05: ft\_sqrt**
   * Create a function that returns the **square root** of a number (if it exists), or **0** if the square root is irrational.
   * Prototype: `int ft_sqrt(int nb);`
7. **Exercise 06: ft\_is\_prime**
   * Create a function that checks if a number is **prime**.
   * Prototype: `int ft_is_prime(int nb);`
   * **0** and **1** are not prime numbers.
8. **Exercise 07: ft\_find\_next\_prime**
   * Create a function that returns the **next prime number** greater than or equal to the given number.
   * Prototype: `int ft_find_next_prime(int nb);`
9. **Exercise 08: The Ten Queens**
   * Create a function that displays all possible placements of **ten queens** on a **10x10 chessboard** without them threatening each other.
   * The function must return the **number of solutions**.
   * Prototype: `int ft_ten_queens_puzzle(void);`

***

#### **Submission and Peer-Evaluation**

* You must submit your work in your **Git repository**.
* Only the files specified in the subject will be evaluated.
* Double-check the names of your files to ensure they are correct.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-guide.gitbook.io/42-guide/piscine-life/c05.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
