Ask Question

Write a while loop that will figure out the factorial of 5 (5!) and print this. It should use two integer variables (i and f) and print f at the end:

+4
Answers (1)
  1. 12 November, 22:24
    0
    void main ()

    {

    int n, i, fact=1;

    printf (""Enter the number/n"");

    scanf (""%d"",&n);

    i=num

    while (i>=1)

    {

    fact=fact * i;

    i--;

    }

    printf (""The factorial of given number %d is %d/n"", n, fact);

    return 0;

    }

    Explanation:

    This program obtains the number for which the factorial has to be found.

    Then run a for loop till the factor of 1 is calculated and inside the for loop the number is multiplied with other numbers in the descending order and finally result is printed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a while loop that will figure out the factorial of 5 (5!) and print this. It should use two integer variables (i and f) and print f ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers