Thursday, January 20, 2011

Write a program to find the factorial value of any number entered through the keyboard.

#include<stdio.h>
main()
{
int number, factorial, temp;

printf("Enter the number whose factorial is to be calculated:");
scanf ("%d", &number);

temp=1;

factorial=1;

while (temp <= number)

{

factorial=factorial*temp;

temp++;


}

printf("The factorial of the entered number is:%d", factorial);
}

No comments:

Post a Comment