my program can't give right answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

my program can't give right answer

#include<iostream> #include<math.h> using namespace std; int main() { float a,b,c,d,dist; cin>>a>>b>>c>>d; a=a-b; c=c-d; dist=sqrt(pow(a,2)) +(pow(c,2)); cout<<dist; }

2nd Dec 2019, 10:37 PM
abdullah
2 Answers
+ 3
Your pow(c,2) is outside the sqrt. So you're doing sqrt( a * a ) + c * c instead of sqrt( a * a + c * c )
2nd Dec 2019, 11:36 PM
Dennis
Dennis - avatar
0
thanks bro
3rd Dec 2019, 3:57 AM
abdullah