jituTechnology

jituTechnology

A program to calculate the factorial of a given number using recursive function.

A program to calculate the factorial of a given number using recursive function.

Codes
/*A program to find the factorial of a number using recursive function*/
/*Programed by          Jitendra Kr Yadav
                         10116
                         15 Mar,2011*/
#include<stdio.h>
#include<conio.h>
int rec(int);
main()
{
int fact,n;
printf(“Enter the number:”);
scanf(“%d”,&n);
fact=rec(n);
printf(“Factorial = %d\n\n”,fact);
printf(“Press any key to continue…”);
getch();
}
int rec(int a)
{
int f;
if(a==1)
return(1);
else
{
f=a*rec(a-1);
return(f);
}
}
Output
Enter the number: 5
Factorial = 120
Press any key to continue…

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

March 2024
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930
31