Popular C Program – Factorial in C

C Language is Basic Language .. Many Advanced Language have come still if u can understand basic language carefully u can do all other languages in easy way. So here is our efforts of giving programs which are well executed in our Rubal Solutions Server and confirm to be running successfully. we have our c programming full tutorial on rubal solutions you tube channel. u can learn theory and practical’s from there … ask any queries if needed.

Factorial Program in C

A Useful and Popular Program in C Programming .

Factorial of number is 123*4….n
To find factorial of a number , u should have knowledge about loops, conditions , operators , data types.

Let’s develop Program for Finding Factorial till given n number in C

#include <stdio.h>
int main()
{
printf("Welcome to Rubal Solutions!\n\n");
printf("Do Like Share Comment Subscribe and Support !\n\n");
int num, iter;
long fact = 1; // initializing factorial to 1
printf("Enter a positive integer: ");
scanf("%d",&num);
if (num < 0) // If the user enters a negative number
printf("The factorial of a negative number does not exist\n");
else
{
for(iter = 1; iter <= num; iter++)
{
fact = fact*iter;
}
printf("The factorial of %d is %lu\n", num, fact);
}
return 0;
}

 426 total views,  3 views today

Share this Post

Leave a Comment

Your email address will not be published.

*
*