UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Posted on 16 Aug 2017 Category: C Views: 963

Edited on 25 Aug 2017

The factorial of a given number is calculated as 1*2*3*….n . Here is another sample program for ‘for loop’.

This program takes a positive integer from the user and compute the factorial using the ‘for loop’.

```
#include <stdio.h>
#include <conio.h>
void main()
{
int n,i,factorial=1; //if we want to find the factorial of a large number we can declare the factorial variable datatype as 'unsigned long long'
printf(“Enter the number :”);
scanf(“%d”,&n);
for(i=0;i<=n;i++)
{
factorial=factorial*i; //compute factorial
}
printf(“The factorial of the number is %d”,factorial);
getch();
}
```

C program to find factorial of a number using While loop

C program to study 'do-while' loop

##### Add two numbers C

##### C program to find factorial of a number

##### C program to generate Multiplication table using for loop

##### C program to study the Conditional Statements

##### C program to study 'Bubble Sort'

##### C program to find largest among two numbers without else.

##### C program to Sort a given set of strings

Contact : [email protected]

User IP : 54.225.31.188