0
What is the meaning of sqrt is not declared
https://code.sololearn.com/clMTaKrdLm8R/?ref=app https://code.sololearn.com/WA22a25a16a7/?ref=app
5 Réponses
+ 2
hita adam
Include math.h or cmath for sqrt and there is no sqr so do (b * b) instead of sqr(b) or you can also use pow method to get power like this pow(b, 2)
https://code.sololearn.com/cM3p9SLpvrGZ/?ref=app
+ 1
sqrt stands for square root
sqrt(4) is √4 (mathematical notation) which is equal to 2 (school maths)
+ 1
Thanks
0
// fixed code - you forgot to include math.h and also there's a typo with sqrt spelling and also imbalanced parenthesis issue
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main () {
double a, b, c, x1, x2;
cin >> a >> a >> c;
x1=(-b+sqrt(sqrt(b)-4*a*c)/2*a);
x2=(-b-sqrt(sqrt(b)-4*a*c)/2*a);
cout << "first root=" << x1 << endl;
cout << "second root=" << x2 << endl;
return 0;
}
0
Ok