It is necessary to assign the number X of a real type to the variable X, for example 1.1. Immediately after typing, the keyboard is rounded off and therefore the wrong answer in the expression and else if does not work. What is the error?
#include <stdio.h> #include <conio.h> #include <math.h> #include <locale.h> float x, w, b = -0.3, c = 4, a = 2.8; int main(void) { setlocale(LC_ALL, "rus"); printf("Для продолжения нажмите любую клавишу..."); getch(); printf("\nВведите переменную x ->"); scanf("%f", &x); if (x < 1.2) { w = a * pow(x, 2) + b*x + c; } else if (x == 1.2) { w = a / x + sqrt(pow(x, 2) + 1); } else { w = (a + b*x) / sqrt(pow(x, 2) + 1); } printf("\aa=%2.1fb=%2.1fc=%1.0fx=%2.1fw=%3.1f", a, b, c, x, w); getch(); printf("\nДля завершения нажмите любую клавишу..."); getch(); return 0; }