Before reading the program you should know what is FACTORIAL and RECURSION ????

/* C/C++ Program To Calculate Factorial Of A Number Using RECURSION */
#include<stdio.h>
#include<conio.h>
long factorial(int); // Function Prototype
void main()
{
int number;
long fact;
clrscr();
printf("Enter a number to find
factorial : );
scanf("%d", &number);
if(number<0 >
printf("Negative numbers are not allowed.\n");
else
{
fact=factorial(num); // Function Calling
printf("%d! = %ld\n",number,fact);
}
getch();
}
long factorial(int x) // Function Defination
{
if (x==0)
return 1;
else
return(x* factorial(x-1)); // Function Calling Itself » Recursion
}

/* C/C++ Program To Calculate Factorial Of A Number Using RECURSION */
#include<stdio.h>
#include<conio.h>
long factorial(int); // Function Prototype
void main()
{
int number;
long fact;
clrscr();
printf("Enter a number to find
factorial : );
scanf("%d", &number);
if(number<0 >
printf("Negative numbers are not allowed.\n");
else
{
fact=factorial(num); // Function Calling
printf("%d! = %ld\n",number,fact);
}
getch();
}
long factorial(int x) // Function Defination
{
if (x==0)
return 1;
else
return(x* factorial(x-1)); // Function Calling Itself » Recursion
}
Contact Us ☎ :
+918679370959
+918679370959
.. FEEL FREE TO COMMENT ..
We Are Happy To Help You.
We Are Happy To Help You.
No comments:
Post a Comment