Functions and Loops
Complete function factorial in the following code snippet using
-
first a for-loop,
-
second a while-loop and
-
third with goto and if statements
Each variant should be equivalent to each other.
#include <stddef.h> #include <stdio.h> #define N 6 size_t factorial(size_t n) { size_t res = 1; // your code here return res; } int main() { printf("result = %zu\n", factorial(N)); return 0; }