Intern — Middle
Identifying bottlenecks in the program's operation
livecode
Task condition
It is necessary to analyze the presented code fragment and identify potential performance issues present in it.
# include <iostream>
# include <cmath>
int main() {
int sum{};
for (;;) {
int num = rand() % 42;
if (num % 2 == 0) {
sum += 2;
} else {
sum += 1;
}
}
}