Please solve my queries . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Please solve my queries .

(1) i haven't understood 4 types of function. What should i do ? (2) also i haven't understood recursion . So should i leave it as it is first language and learn it in D.S.A. or what should i do ?

15th Mar 2022, 3:22 PM
Abhay mishra
Abhay mishra - avatar
3 Answers
+ 2
A function is recursive ,if it calls itself repeated.. Like : A() { //.. A(); //.. } You must put a condition to stop iteration. Otherwise it's infinite recursion. The condition is called a base condition. What do mean by 4 types of functions there?
15th Mar 2022, 3:41 PM
Jayakrishna 🇮🇳
+ 2
Jayakrishna🇮🇳 sir , 4 types means (1) Both argument and return value . (2) No argument but return value. (3) argument but no return value. (4) no argument and no return Both .
15th Mar 2022, 3:55 PM
Abhay mishra
Abhay mishra - avatar
0
A function syntax : A function contains function definition and function calling statements.. Function definition: <return_type> function_name( arguments) { //body } return_type is any data type or void. So function returns a value back to calling statement. If it is void means it does not return anything. <argument> are a list of data values passed to functions. , in the form: (<type> <name>, .......) there may be any number of arguments from zero to n. Hope you know, how to declare: Ex: Declaration: void print(int i); Definition: void print(int i) { printf("%d , Hello", i); } Calling : print(5); (1) Both argument and return value . int get(int i) { return a[I]; } //returns value at index I from array a. (2) No argument but return value. int pop() { return a[0]; } //returns value at index 0 (3) argument but no return value. void display(char name[]) { printf("%s", name) ; } //argument passed a character array. nothing returns (4)no argument and no return Both . void print(){ printf("hi"); }
15th Mar 2022, 4:32 PM
Jayakrishna 🇮🇳