+ 1

Can some Body Solve this Tipical Logicall error

#include<iostream> #include<conio.h> #include<math.h> using namespace std; int main() { int a,b,c,x,lar,slar,tlar; //a b c are sides of triangle cin>>a>>b>>c; do{ if((pow(a,2)+pow(b,2)==pow(c,2))||(pow(b,2)+pow(c,2)==pow(a,2))||(pow(c,2)+pow(a,2)==pow(b,2))) { x=1; if(a>b) { if(a>c) { lar==a; slar==c; tlar==b; } else { lar==c; slar==a; tlar==b; } } else { if(b>c) { lar==b; slar==c; tlar==a; } else { lar==c; slar==b; tlar==a; } } float sin,cos,tan; sin = tlar/lar; cos = slar/lar; tan = tlar/slar; cout<<"H"<<lar; cout<<"B"<<slar; cout<<"P"<<tlar; cout<<0<<"=\t"<<sin; cout<<0<<"=\t"<<cos; cout<<0<<"=\t"<<tan; int rootfive,theta; rootfive=sqrt(5); theta=(lar*rootfive)/tlar; cout<<0<<"\t=\t"<<theta; } else { cout<<"wrong entry"; break; } }while(x!=1); return 0; }

16th Nov 2016, 1:05 PM
manas srivastava
manas srivastava - avatar
1 Answer
+ 2
One basic difference between "==" operator and "=" operator is "==" operator is "equality operator" and is used for comparing the value on right side of "==" operator is equal to the value on left side of the operator. While "=" is the "assignment operator" and is used to assign value on right side of the operator to left side variable. Solution: In the above code in if-else cases when u are assigning values of a,b,c to lar, slar, tlar instead of using "==" operator use "=" operator. This should solve your logical error. Please correct me in m wrong, looking forward for your inputs. ^_^
16th Nov 2016, 2:25 PM
Pranjal Upadhyay
Pranjal Upadhyay - avatar