Sobes.tech
Junior — Senior

Error detection in the program

livecode

Task condition

It is necessary to analyze the provided code fragment and identify any logical or technical issues present in it.

#include <iostream>
#include <cmath>

int main(void) {
    const int N = 100;
    const double Y = 20;
    const double step = Y / N;

    for (double val = Y; val > 0; val -= step) {
        std::cout << val << " ; ";
        if (val == 2.0)
            std::cout << "This is the desired value: " << val << std::endl;
    }

    std::cout << std::endl;
}