Saturday, 14 January 2012

To find the FACTORIAL of a number using RECURSION


#include<stdio.h>
#include<conio.h>
void main()
{
int fact(int);
int n,f;
clrscr();
printf("enter a no.\n");
scanf("%d",&n);

if(n<0)
printf("\ninvalid no.");
else
{
f=fact(n);
printf("\n factorial=%d",f);
}
getch();
}
int fact(int n)
{
if(n==0)
return 1;
else
if(n==1)
return 1;
else
return(n*fact(n-1));
}

For 8051 microcontroller programming :http://assemblylanguage8051.blogspot.in/

Jai Ho - HD Hindi Movie Digital Poster [2014] Salman Khan by A-Music

No comments:

Post a Comment