Найти количество отрицательных значений функции- C++(Си)

#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
        int c=0;
        float x, y;
        for (x=.3; x<=5; x+=.1)
        {
        
                y=cos(pow(x,2))*exp(-x);
                if (y<0) c++;
                cout<<"x="<<fixed<<setprecision(2)<<x<<"   y="<<y<<endl;
        }
        cout<<c<<'\n';
        cin.get();
        return 0;
}

Leave a Comment