Wednesday, September 15, 2010
display a c programme of factorial of n?
Answer:
Dear,
U aligned today. Welcome.... U will surely find u r answers.
Here it is:
void main()
{
int num;
long int factorial;
factorial=1;
printf("\n Enter a number : ");
scanf("%d",&num);
while(num>=1)
{
factorial= factorial * num;
num=num-1;
}
printf("\n The factorial is %ld.",factorial);
}
OM NAMAH SHIVAY
#include <stdio.h>
int factorial (int n)
{
if (n == 0)
return 1;
else
return (n * factorial (n-1));
}
/* To shorten example, not using argp */
int chief ()
{
printf ("%d\n", factorial(3)); // give the required number
return 0;
}
not a nice put somebody through the mill to be asked this is a very simple one and u can smoothly get into it
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
negated main()
{
int a,num,fact;
fact=1;
printf("Enter the number");
scanf("%d",&num);
flushall();
system("cls");
for(a=1;a<=num;a++)
fact=fact*a;
printf("The factorial is %d",fact);
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment