c program to print factorial of a number using function


A function, depending on whether arguments are present or not and whether a value is returned or not, may belong to one of the following categories: A function ….

Category 1:  With    Return   With  Argument

Category 2:  No       Return   With  Argument

Category 3:  No       Return   No      Argument

Category 4:  With   Return   No      Argument

Category 5:  Functions that return multiple values.( using  with pointer )


1.  With    Return   With  Argument

A  Function With Return a  Value  and  Passing Arguments

A function have  one or more Arguments means input values passing to the Called function   and also   it does  receive a  value  from the Calling function. this type of mechanism in UDF is With Return Type and With Argument Type.

In effect, there is  data transfer between the calling function and the called function.

Example Program for …

Find  Factorial using User Defined Function with Return Type and with  Argument Type

Source code

Output of Factorial Program in C using UDF(With    Return   With  Argument)

Enter any Value : 5
Factorial of  5 = 120


2.   No       Return   With  Argument

A Function No Return any  Value but  Passing any Arguments

A function have  one or more Arguments means input values passing to the Called function   and  but it does  not   receive  any  value  from the Calling function. This type of mechanism in UDF is No Return Type and With Argument Type.

 

Example Program for …

Find Factorial using UDF  No Return Type but passing Argument Type

Source code

Output of Factorial Program in C using UDF(No       Return   With  Argument)

Enter any Value : 5
Factorial of  5 = 120

 


3.  No       Return   No      Argument

A Function  No Return any  Value and No passing any Arguments

A function have not passing any Arguments  Value from the Calling function   and  also does  not  get  receive  any  value  from the Called  function. This type of mechanism in UDF is No Return Type and With Argument Type.

In effect, there is  no  data transfer between the calling function and the called function.

Example Program for …

Find  Factorial using User Defined Function No Return Type and No Argument Type

Source code

 

Output of Factorial Program in C using UDF(No       Return   No      Argument)

Enter any Value : 5
Factorial of  5 = 120

 


4.  With   Return   No      Argument

A Function  With Return any  Value But  No passing any Arguments

A function have not passing any Arguments  Value from the Calling function   but it   get   means receive  any  value  from the Called  function. This type of mechanism in UDF is  With Return Type and No Argument Type.

 

Example Program for …

Find  Factorial using User Defined Function With Return Type and No Argument Type

Source code

 

Output of Factorial Program in C using UDF (With Return   No      Argument)

Enter any Value : 5
Factorial  = 120

 

 

(Visited 2,058 times, 1 visits today)

1 thought on “c program to print factorial of a number using function

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image