WSQ06 – Factorial Calculator

I completed the task of making a program that calculates the factorial of a number.

I learnt the Mastery Topic #13 & #16, do while loops and recursions.

I created a function called factorial that used a recursion to repeat the same operation several times. This is my function:

int factorial (int n){
int answer;
answer=1;
while (n>1){
answer = answer * n;
n=n-1;
}
return answer;
}

I did a do-while loop to keep asking the user if they would like the program to calculate a factorial of a number again.

For this assignment I learnt what an unsigned integer is, as well as a char

Captura3

 

6 comentarios en “WSQ06 – Factorial Calculator

  1. Pingback: Calculadora Factorial – RON

  2. Pingback: Factorial Calculator – Inplamura

Deja un comentario