i was making program calculate basic things about shapes but when i used acos()
for calculating angles between sides it didnt work it only gave the value of angle it just ignored acos()
Yeah i also kept that in mind and than also i didnt get the right output
1 2 3 4 5 6
a1=((s3*s3)+(s2*s2)-(s1*s1))/(2*s3*s2);
a2=((s1*s1)+(s3*s3)-(s2*s2))/(2*s1*s3);
a3=((s1*s1)+(s2*s2)-(s3*s3))/(2*s1*s2);
cout<<"\nAngle Between Sides "<<s3<<" and "<<s2<<" is : "<<(acos(a1)*180)/M_PI
<<"\nAngle Between Sides "<<s1<<" and "<<s3<<" is : "<<(acos(a2)*180)/M_PI
<<"\nAngle Between Sides "<<s1<<" and "<<s2<<" is : "<<(acos(a3)*180)/M_PI;
This is the concerned region of my code please help me find the mistake which i am not able to figure out.
I am only getting values of a1,a2,a3 as my output when i run the code.
What type is s1, s2 etc. If they are integers you are a victim of integer division and all the angles will be 90 degrees. Change them to doubles or change 2 to 2.0 in each denominator.
they all are of float type will this effect them. BTW a1,a2 and a3 are calculated correctly but the part in cout is just ignored by the compiler and gives the output of just a1,a2,a3 instead of calculating the full value with acos and the converting it to degrees it just ignores it.
i figured out the mistake the code here is correct but the cout statement given in the beginning has wrong numbering and the switch statement also followed the same that was the mistake. Sorry!!! for wasting your precious time SORRY
And BTW Thanks For Your Help