Introduction
Recursion is a programming technique where a function calls itself, allowing the function to repeat until a base case is met and the function returns the final output. In this lab, we will learn how to find the sum of digits of a given number using recursion.
Note: You need to create the file ~/project/main.c
yourself to practice coding and learn how to compile and run it using gcc.
cd ~/project
## create main.c
touch main.c
## compile main.c
gcc main.c -o main
## run main
./main
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
c(("`C`")) -.-> c/UserInteractionGroup(["`User Interaction`"])
c(("`C`")) -.-> c/BasicsGroup(["`Basics`"])
c(("`C`")) -.-> c/ControlFlowGroup(["`Control Flow`"])
c(("`C`")) -.-> c/PointersandMemoryGroup(["`Pointers and Memory`"])
c(("`C`")) -.-> c/FunctionsGroup(["`Functions`"])
c/UserInteractionGroup -.-> c/output("`Output`")
c/BasicsGroup -.-> c/comments("`Comments`")
c/BasicsGroup -.-> c/variables("`Variables`")
c/BasicsGroup -.-> c/data_types("`Data Types`")
c/BasicsGroup -.-> c/operators("`Operators`")
c/ControlFlowGroup -.-> c/if_else("`If...Else`")
c/UserInteractionGroup -.-> c/user_input("`User Input`")
c/PointersandMemoryGroup -.-> c/memory_address("`Memory Address`")
c/PointersandMemoryGroup -.-> c/pointers("`Pointers`")
c/FunctionsGroup -.-> c/function_parameters("`Function Parameters`")
c/FunctionsGroup -.-> c/function_declaration("`Function Declaration`")
c/FunctionsGroup -.-> c/recursion("`Recursion`")
subgraph Lab Skills
c/output -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/comments -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/variables -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/data_types -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/operators -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/if_else -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/user_input -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/memory_address -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/pointers -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/function_parameters -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/function_declaration -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
c/recursion -.-> lab-123340{{"`Sum of Digits Using Recursion`"}}
end