Write a factorial Program in C C++ Programming Language Simple code using For Loop
#include<stdio.h>
#include<conio.h>
int factorial(int i)
{
int k;
for(; i<=k; i++)
k=i*k;
return k;
}
void main()
{
int fact,a;
clrscr();
printf("enter the number");
scanf("%d",&a);
fact=factorial(fact);
printf("%d",fact);
getche();
}
#include<stdio.h>
#include<conio.h>
int factorial(int i)
{
int k;
for(; i<=k; i++)
k=i*k;
return k;
}
void main()
{
int fact,a;
clrscr();
printf("enter the number");
scanf("%d",&a);
fact=factorial(fact);
printf("%d",fact);
getche();
}
0 comments:
Post a Comment