Saturday, July 2, 2016


Important programs of C

//WAP to find and display the factorial of n number using function

#include<stdio.h>
#include<conio.h>

long int fact(int n)
{
if(n==0)
return 1;
else if(n==1)
return 1;
else
return(n*fact(n-1));
}

void main()
{int n;
clrscr();

printf("enter a number\t");
scanf("%d",&n);

printf("\nFactorial number is: %ld",fact(n));

getch();
}

Labels:

0 Comments:

Post a Comment

thank you

Subscribe to Post Comments [Atom]

<< Home