Вопрос задан 23.07.2023 в 00:41. Предмет Информатика. Спрашивает Гура Коля.

Var a,b,d,c:integer; begin d:=sqr(9)=4*a*c; IF d<0 THEN cообщить;нет;решения;

x1:=(-b+sqrt(D))/2*a; write ;сообщить;результат; end где ошибка в 4 строке?
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Краснушкина Дарья.

Двоеточие, скобочка?

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

The error in the 4th line is due to the incorrect usage of the sqr function. The sqr function calculates the square of a number, but in this context, it seems like you want to calculate the discriminant of a quadratic equation.

The correct formula for the discriminant (D) of a quadratic equation ax^2 + bx + c = 0 is:

css
D = b^2 - 4ac

So, the correct way to calculate the discriminant in your code should be:

pascal
Var a, b, d, c: integer; begin d := sqr(b) - 4 * a * c; // Corrected line to calculate the discriminant IF d < 0 THEN writeln('Нет решения') else begin x1 := (-b + sqrt(d)) / (2 * a); writeln('Результат: ', x1); end; end.

Here, I've also corrected the usage of writeln to display the messages properly. The code now correctly calculates the discriminant (d) and checks if it's less than 0 to determine if the quadratic equation has real roots or not.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос