Так что я пытаюсь создать программу, которая вычисляет квадратичную формулу, но когда я пытаюсь скомпилировать код, я получаю следующее: «неопределенная ссылка на sqrt» Но я попытался определить sqrt через математику .h и еще 2 раза в коде. Я приложил свой код Любая помощь будет принята с благодарностьюФункция Sqrt не работает
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
double sqrt(double);
int main (void) {
double sqrt(double);
int a,b,c;
double discriminant,squarerootofdis,root1, root2;
printf("Please enter the coefficient of x^2:");
scanf("%d",&a);
printf("Please enter the coefficient of x:");
scanf("%d",&b);
printf("Please enter the integer value of the ploynomial:");
scanf("%d",&c);
if (a==0 && b==0)
{printf("This case is extremely degenerate");}
else if (a==0 && b!=0)
{root1=-c/b;
printf("Degenerate one real root: %lf\n",root1);}
else{
discriminant = ((b*b)-(4*a*c));
squarerootofdis = sqrt(discriminant);
root1 = (squarerootofdis-b)/(2*a);
root2 = (-squarerootofdis-b)/(2*a);
if (discriminant>0)
printf("Two real roots: %lf\n %lf\n", root1, root2);
else if (discriminant == 0)
printf("Degenerate one real root: %lf\n",root1);
else if (discriminant<0)
printf("Two complex roots: %lf\n %lf\n", root1, root2);
}
}
Что это связано с Emacs? –
Я сделал код в emacs – Mike
, так что ничего, я удаляю тег 'emacs' –