JirR02 7b86ebfe6a Exercise 3
Added Exercise 3 with solutions and README to Repository
2025-03-07 23:04:40 +01:00
..
2025-03-07 23:04:40 +01:00
2025-03-07 23:04:40 +01:00

This task is a mixed text/programming task. You need to update the content of loop.cpp according to the instruction provided in the file. For the code part, please check the autograder output.

Task

Considering the snippet

int n;
std::cin >> n;
int f = 1;
if (n > 0) {
  do {
    f = f * n;
    --n;
  } while (n > 0);
}
std::cout << f << std::endl;
  1. Describe what it computes.
  2. Decide which of the other two kind of loops would fit better than the one it is currently using, and describe why.
  3. Rewrite the snippet into the loop you specified in (2). This part is autograded.

Important: The use of goto statements is prohibited.