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, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment