0

Function and recursion

I don't understand why we call function the function during declaration we can separate also make it why there is many types of functions like void ,int etc

30th Jan 2025, 2:38 PM
Avinash Kumar
Avinash Kumar - avatar
2 Respuestas
+ 1
Avinash Kumar I am not sure what you are asking. You might try typing the question into Google Translate and paste here, or just ask it in your native language. A recursive function is any function which calls itself. Recursion is not dependent on the data type of the function's return value or any of its arguments. The only criteria for a properly coded recursive function is at least one argument which will change with each recursive function call and be used to determine when the recursive calls end.
30th Jan 2025, 5:02 PM
Shardis Wolfe
+ 1
It seems you are asking two questions. 1. Why use recursion function; 2. Why void, int, etc. Why use recursion function? First of all, a recursion function is a function calls itself. It would be useful to find a solution. For example, there is a field with Width 1680m and length 640m. What is the plot of field can be divided which is a square? You can get two 640 x 640m fields, and a 400 x 640m fields undivided, Then you can use the same technique to divide the undivided field. By repeating this process, you will find the square would be 80 x 80M. (An example from a book: Grokking Algorithms, An Illustrated Guide for Programmers and Other Curious People, by Aditya Y. Bhargave) 2. Why void, int, etc? These keywords indicate the return data type. void returns nothing, and int returns an integer.
31st Jan 2025, 3:48 AM
Wong Hei Ming
Wong Hei Ming - avatar