Sunday, September 2, 2012

Factorial of a Number Using While loop in C program

Factorial of a Number Using While loop in C program

This is program to find out factorial of a number using simple while loop. this logic use to create a function like fact to find out any factorial of number /Integer.

/* Program For Factorial Of a No.*/
#include<stdio.h>

int main()
{
int no,temp=1;
printf("\nEnter no\n");
scanf("%d",&no);

int fact=1;
while(1)
{
if(temp>no)
 break;
fact=fact*temp;
temp++;
}

printf("Factorial of No    %d \t is :%d\n",no,fact);
return 0;


}



0 comments:

Post a Comment