89.7k views
1 vote
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:

1 Answer

7 votes

Answer:

void main()

{

int n, i, fact=1;

printf(""Enter the number\\"");

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

i=num

while(i>=1)

{

fact=fact * i;

i--;

}

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

return 0;

}

Step-by-step 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.

User Rastalamm
by
7.0k points