In this task, we needed to create a program that ask the user for any nonnegative number to calculate its factorial and print the result on the screen. To do it, I used the for loop, a repetition control structure, which made things easier. Here is the program:
The for loop has the following sintax:
for (init; condition; increment){
statements
}
In init, you can declare and initialize any loop control variables; in condition, the condition is evaluated and, if it is true, the body of the loop is executed, if false, it will stop; and, in increment, you can update any loop control variables.
Here’s the program being executed:
To do this activiy, I consulted this web page: http:/
You can look at my code in my GitHub as well: https:/
#WSQ09 Factorial by Alan Valdovinos is licensed under a Creative Commons Attribution 4.0 International License.