Z
Z
Zhenia Bel2021-10-17 20:11:04
C++ / C#
Zhenia Bel, 2021-10-17 20:11:04

Outputs that y = ?, how to fix it?

Here is my code:

class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Введите a:");
            double a  = Convert.ToDouble(Console.ReadLine());
            Console.Write("Введите b:");
            double b = Convert.ToDouble(Console.ReadLine());
            Console.Write("Введите c:");
            double c = Convert.ToDouble(Console.ReadLine());
            Console.Write("Введите d:");
            double d = Convert.ToDouble(Console.ReadLine());

            double x = (a + 2 * b - c + d) / (c * d) + (a + b) / (c - d) - (a * a) / (b * b);
            double y = (5 * (a + b) * (c - b)) / (1 / 2 * c) + d * d * (a * a - b * b) / (b - a);
            double z = (((x * x - 2 * x) - 4 * (x * x * x * x + 1)) * (1 - b)) / (5 * a + 3 * b);
            double r = (1/2*a+3/4*b-7/5)/(3*c+1)+ 1 / (a - c);
            Console.Write($"x = {x}, y = {y}, z ={z}, r = {r}  ");
        }
    }

616c591d1ebb8021782362.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-10-17
@vabka

x = -3.5308641975308643, y = -∞, z =93.25781896015157, r = 0.4

"y" is "minus infinity"
You just don't have the right character in the font you're using.
How to fix - FIG knows.
Maybe you have an error in the formula.
If this is the norm - just check if your number is infinity using the method Double.IsInfinity, Double.IsPositiveInfinity, Double.IsNegativeInfinity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question