Triangle-Programm

The program should operate as follows:

Only the user must enter any values (a, b, c, alpha, beta, gamma).
Then the program will calculate the angles and sides.
At the end of a table is now to be issued, which shows all six values.

I started like this:
#include <iostream>
#include <conio.h>

#define PI 3.14159265

using namespace std;

main(){
       double a, b, c, alpha, beta, gamma;
       
       a=0;
       b=0;
       c=0;
       alpha=0;
       beta=0;
       gamma=0;

       cin>>a;
       cout<<"b="<<"\t";
       cin>>c;
       cout<<"c="<<"\t";
       cin>>alpha;
       cout<<"Alpha="<<"\t";
       cin>>beta;
       cout<<"Beta="<<"\t";
       cin>>gamma;
       cout<<"Gamma="<<"\t";
       if(a=b=c){
                 cout<<"a="<<"\t"<<a<<endl;
                 cout<<"b="<<"\t"<<b<<endl;
                 cout<<"c="<<"\t"<<c<<endl;
                 cout<<"alpha="<<"\t"<<"60°"<<endl;
                 cout<<"beta="<<"\t"<<"60°"<<endl;
                 cout<<"gamma="<<"\t"<<"60°"<<endl;
                 }
       else if(beta!=0&&a!=0&&gamma!=0){
                                                 alpha=180-beta-gamma;
                                                 b=a/sin(alpha)*sin(beta);
                                                 c=a/sin(alpha)*sin(gamma);
                                                 cout<<"a="<<"\t"<<a<<endl;
                                                 cout<<"b="<<"\t"<<b<<endl;
                                                 cout<<"c="<<"\t"<<c<<endl;
                                                 cout<<"alpha="<<"\t"<<alpha<<"°"<<endl;
                                                 cout<<"beta="<<"\t"<<beta<<"°"<<endl;
                                                 cout<<"gamma="<<"\t"<<gamma<<"°"<<endl;


And there it won´t work.

I would be happy about the program.

Sincerely Toudo
Won't work ain't an error description.
Two obvious mistakes are main() (must be int main()) and if (a=b=c) (must be a==b && a==c).
closed account (D80DSL3A)
Some other problems ( in addition to those noted by Athar ):
1) Data input is flawed. Program begins by with cin>>a. without a prompt to the user how would he/she know what is to be entered? User is then prompted for the value of b, but it is stored in c. After this point all the cin/cout sequences are reversed ( reading a value and then prompting for it is backwards ).
2) I think the trig. functions work with angles measured in radians not degrees. If user is to enter angles in degrees then use sin(alpha*PI/180) instead of sin(alpha), etc.
3) The problem treatment itself may be flawed. Only a subset of the side/angle values are needed to determine the values of the others. User is over specifying the geometry of the triangle by entering all 6 values. It looks like your code is set up to calculate alpha, b and c in terms of given a, beta and gamma. Your program therefore should only prompt the user for a, beta and gamma.
4) Since your variables are type double I think you want to initialize them with 0.0 not just 0
eg: a = 0.0; Good luck!
Topic archived. No new replies allowed.