Calling / Arguments / Recursion :

About function calling in C language :

A function is called by the calling program using the function name with the required number of arguments in parentheses. The function call appears in an assignment statement or in an output statement.

Actual and formal arguments :

Actual :

The arguments listed in the function calling statement are referred to as actual arguments. They are the actual values passed to a function to compute a value or to perform a task. Consider a function call statement with actual arguments as given below.

ncr = fact(n)/(fact(n-r)*fact(r));

Formal :

The arguments used in the function declaration are referred as formal arguments. They are simply formal variables that accept or receive the values supplied by the calling program. Consider a function call statement with formal arguments as given below.

int fact(int k)
int i, p = 1;
for(i = 1; i <= k; i++)
p = p * i;

Note : That the number of actual and formal arguments and their data types should match.

Recursion :

A function calling itself again and again to computer a value is referred to recursive function or recursion. Normally a function is called by the main program or by some other function but in recursion the same function is called by itself repeatedly.

Use of Recursive Function :

Recursive function are written with less number of statements compared functions. Recursive is effective where terms are generated successively to computer a value. Recursive is useful for branching processes. Recursion helps to create to create short code that would otherwise be impossible.

Example :

  1. /* Description: find a factorial number use recursive function */
  2. #include<stdio.h>
  3. main()
  4. {
  5. int factorial(int);
  6. int num,result;
  7. printf("Entar a number : ");
  8. scanf("%d",&num);
  9. result=factorial(num);
  10. printf("The factorial of %d is %d.",num,result);
  11. getch();
  12. }
  13. int factorial(int num)
  14. {
  15. if(num==1)
  16. {
  17. return 1;
  18. }
  19. else
  20. {
  21. return(num * factorial(num-1));
  22. }
  23. }

Output :

c language - find a factorial number use recursive function

Next Update


We create a new YouTube channel (NightHawk) for gaming purpose like online games streaming or games review.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels

Protection died IPs active, this IP range is not allowed !