//program to get factorial value of a positive number
#include<stdio.h>
include<conio.h>
void main()
{
int number,fact=1,i;
printf("enter any positive number\n");
scanf("%d",&number);
if(number>0)
{
for(i=1;i<=number;i++)
{
fact=fact*i;
}
}
else
{
printf("the number is not +ve\n");
}
printf("the factorial value for entered number=%d is =%d\n",number,fact);
getch();
}
------------------------------
logics in mind:
->enter a number whose factorial value you want to find
->we have to go for repetitive multiplication from number 1 to entered number 'number'. This we can apply using loop as shown above.
->display the final value of variable 'fact'.
#include<stdio.h>
include<conio.h>
void main()
{
int number,fact=1,i;
printf("enter any positive number\n");
scanf("%d",&number);
if(number>0)
{
for(i=1;i<=number;i++)
{
fact=fact*i;
}
}
else
{
printf("the number is not +ve\n");
}
printf("the factorial value for entered number=%d is =%d\n",number,fact);
getch();
}
------------------------------
logics in mind:
->enter a number whose factorial value you want to find
->we have to go for repetitive multiplication from number 1 to entered number 'number'. This we can apply using loop as shown above.
->display the final value of variable 'fact'.