C Program For Factorial of a number using function

#include<stdio.h>
#include<conio.h>
int fact(int);
void main(void)
{
int n,res,i;
clrscr();
printf("Enter number");
scanf("%d",&n);
res=fact(n);
printf("%d!=%d",n,res);
getch();
}
 int fact(int n)
 {
 int i,res;
 i=1;
 res=1;
 while(i<=n)
 {
 res=res*i;
 i++;
 }
 return res;
 }
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment