Posts

Showing posts with the label factorial program

Basic program #2

Image
2. Read any number and find factorial of a number. (Using Loop) #include <stdio.h> int main() {     int n, i;     unsigned long long factorial = 1;     printf("Enter an integer to find it's factorial: ");     scanf("%d",&n);      // show error if the user enters a negative integer     if (n < 0)         printf("Error! Factorial of a negative number doesn't exist.");     else     {            i=1;         while(i<=n)         {             factorial *= i;              // factorial = factorial*i;             i++; ...