if w funkcji for

0
 
#include <iostream>
#include <math.h>
#include <fstream>

using namespace std;

int main()
{
    double y,x;

    fstream file;
    file.open("Zadanie3.txt" , ios::trunc | ios::out);

    for (x=3; x<=6; x+=0.2)
    {
        if (x<4)
        {
            y=log(x)-cos(x);
            file <<"x= "<< x << ", y= "<< y <<endl;
        }

        if(x>=4 && x<5)
        {
            y=34/(10-50*log(x));
             file <<"x= "<< x << ", y= "<< y <<endl;
        }

        if(x>=5)
        {
            if ((x-50)<0)
                {
                    file <<"Dla x= "<< x <<" podstawa logarytmowana jest ujemna, czyli logarytm nie istnieje."<<endl;
                }
            else
                {
                    y=pow(log(x-50),2);
                    file <<"x= "<< x << ", y= "<< y <<endl;
                }
        }
    }
    return 0;
}

Czemu nie wypisuje mi 6?

1

Poczytaj o reprezentacji liczb zmiennoprzecinkowych w komputerach.

1 użytkowników online, w tym zalogowanych: 0, gości: 1