N
N
Nikikez2021-10-21 15:11:26
C++ / C#
Nikikez, 2021-10-21 15:11:26

Where is my error in the while loop?

static void Main(string[] args)
        {
            double x, b, h;
            Console.Write("Введитe x: ");
            x = double.Parse(Console.ReadLine());
            Console.Write("Введите b: ");
            b = double.Parse(Console.ReadLine());
            Console.Write("Введите шаг вычисления h: ");
            h = double.Parse(Console.ReadLine());
            double y = 0;

            while (y <= b)
            {
                if (x < 0) y = Math.Pow((Math.Pow(x, 3) + 1), 2);
                else if (0 <= x && x < 1) y = 0;
                else if (x >= 1) y = Math.Abs(Math.Pow(x, 2) - 5 * x + 1);
                x += h;
                Console.WriteLine("Таблица значений функций: " + y);
            }
        }

In general, my task is to build a table of function values.
6171589d59bf1628689832.jpeg
For x ∈ [a,b] with step h.
I don't understand where is my mistake?
I hope for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AndromedaStar, 2021-10-21
@AndromedaStar

while (x <= b), it is necessary because x ∈ [a,b] with step h.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question