CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,fac,*p1,*p2;
clrscr();
p1=#
p2=&fac;
printf("Enter any number ");
scanf("%d",p1);
fac=1;
for(i=1;i<=*p1;i++)
{
*p2=*p2*i;
}
printf("\nFactorial of %d is = %d",*p1,*p2);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,fac,*p1,*p2;
clrscr();
p1=#
p2=&fac;
printf("Enter any number ");
scanf("%d",p1);
fac=1;
for(i=1;i<=*p1;i++)
{
*p2=*p2*i;
}
printf("\nFactorial of %d is = %d",*p1,*p2);
getch();
}
CODING |
OUTPUT |
For any query or suggestion please comment below...
Factorial Program in C++
ReplyDeletein c++ you can easily write Factorial of any number, it is the product of an integer and all the integers below it for example factorial of 5 is
5! = 5 * 4 * 3 * 2 * 1 = 120. factorial program in c++ is very simple and easy.
This article is very clean and useful for using pointers in c Language .
ReplyDeletethanks