{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software). like dev c++ Download Code::Blocks,dev c++ its free and install it in your computer.open dev c++ go to file-->new-->source file.}
#include<stdio.h>
#include<conio.h>
main()
{
int f=1,c,n;
printf("enter a number\n");
scanf("%d",&n);
for(c=1;c<=n;c++)
f=f*c;
printf("factorial of %d is %d",n,f);
getch();
}
or
#include<stdio.h>
#include<conio.h>
main()
{
int f=1,c=1,n;
printf("enter a number\n");
scanf("%d",&n);
while(c<=n)
{
f=f*c;
c++;
}
printf("factorial of %d is %d",n,f);
getch();
}
For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}
IS IT HELPFIL? comment.
No comments:
Post a Comment