100% C program factorial of a natural number
// program to print factorial of a given natural number
#include <stdio.h>
void main()
{
int i,n,factoria=1;
printf("\n enter a natural number whose factorial is required:");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
factoria=factoria*i;
}
printf("\n the factorial of %d is %d",n,factoria);
}
enter a natural number whose factorial is required:7
the factorial of 7 is 5040
#include <stdio.h>
void main()
{
int i,n,factoria=1;
printf("\n enter a natural number whose factorial is required:");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
factoria=factoria*i;
}
printf("\n the factorial of %d is %d",n,factoria);
}
ఔట్పుట్ తెరమీద ఇలా
enter a natural number whose factorial is required:7
the factorial of 7 is 5040
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.