These predefined functions provided by programming languages or libraries to perform common tasks such as mathematical calculations, input/output, or string operations.
For example, the sqrt() function from the C++ <cmath> library calculates the square root of a number.
Output
Square Root: 5
User-defined
These functions are functions written by programmers to perform specific tasks required in a program.
They help organize code and allow reuse of logic whenever needed.
Output
Hello, World!
Function Visualizer
Where are Functions Used in DSA?
In DSA, functions are used to implement algorithms and solve problems in a structured and reusable way.
Implement algorithms like searching and sorting.
Handle recursion (like factorial, tree traversal).
Break problems into smaller subproblems.
Operate on data structures like arrays, linked lists, trees, and graphs.