Friday, 15 June 2018

Program to find factorial of a number by using user define function in C

/* function prototype */
# include <stdio.h>
int fact (int) ;
void main ()
{
int a,b ;
clrscr () ;
printf ("\n enter the value of a:") ;
scanf ("%d", & a) ;
b = factorial(a) ;
getch () ;
}
int factorial (int a)
{
int fact = 1 ;
while (a!=0)
{
fact=fact*a ;
a-- ;
}
getch ;
}


No comments:

Post a Comment

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...