1. Mat...I tried this,but it returns wrong values -:
Code:
```void Program::Trigonometry()
{
double pi = 3.1416; //Again for trigo.
if (g[0] == 'M' || 'm')
{
setcolor(7);
cout << "Enter angle theta (degrees) -";
cin >> degrees;
a == degrees * (pi/180);
Sine = sin (a * (180/pi));
Cosine = cos (a * (180/pi)) ;
Tangent = tan (a * (180/pi));
Arctan = atan (a * (180/pi));
Arccos = acos (a * (180/pi));
Arcsine = asin (a * (180/pi));

}
else if (g[0] == 'N' || 'n')
{
setcolor(7);
cout << "Enter angle theta(radians) -";
cin.ignore();
Sine = sin (a);
Cosine = cos (a);
Tangent = tan (a);
Arctan = atan (a);
Arccos = acos (a);
Arcsine = asin (a);
}
cout << "\nThe trigonometric ratios are as follows -:\n";
setcolor(14);
cout << "Sin theta = " << Sine << endl;
cout << "Cos theta = " << Cosine << endl;
cout << "Tan theta = " << Tangent << endl;
cout << "Inverse Sin(Arcsine) theta = " << Arcsine << endl;
cout << "Inverse Cos(Arccos) theta = " << Arccos << endl;
cout << "Inverse Tan(Arctan) theta = " << Arctan << endl;
}```
I try any angle,'cos' always comes 1,and the rest the same garbage.

2. Code:
`a == degrees * (pi/180);`
Guess you want
Code:
`a = degrees * (pi/180);`
Kurt
EDIT:
same here
Code:
`a == radians;`

3. > else if (g[0] == 'N' || 'n')

else if (g[0] == 'N' || g[0] == 'n' )

Or maybe
else if ( toupper(g[0]) == 'N' )

4. The trig functions take arguments in radians. You've correctly converted a from degrees to radians, then incorrectly converted it right back to degrees inside the arguments to each of the trig functions.

5. I was thinking pretty much the same thing...it accepts arguements in radians. How do I make it accept args in degrees? Then I'd convert degrees to radians,feed it to the computer and get an output based on that. And Salem that if else works anyway :P

6. > And Salem that if else works anyway :P
Oh I'm sure it compiles, and perhaps through some random chance you occasionally see what you expect to see.
But for sure it is NOT the way to compare a variable with an upper case or lower case letter.

7. Hmm k I see,I'll implement what you said...but what about the accepting args in degrees part..some help on that please

8. Originally Posted by SVXX
Hmm k I see,I'll implement what you said...but what about the accepting args in degrees part..some help on that please
You don't give args in degrees, you give them in radians (why did you convert the angle from degrees to radians if you didn't think you were supposed to use it?). For example:
Code:
```std::cin >> degrees;
a = degrees * (pi/180); // a is angle in radians
Sine = sin(a);  // this works properly now```

9. Code:
`if (g[0] == 'N' || 'n')`
If we split this into parts, we get if (g[0] == 'N') or ('n' != 0) - well, 'n' is not zero in any alphabet representation that I've even heard the name of, so this will ALWAYS be true.

Yes, it compiles - the compiler may give you warnings if you enable -Wall to say "this is always true", but perhaps not.

--
Mats

Code:
```void Program::Case6()
{
cin >> g;
cin.ignore();
setcolor(13);
if (g[0] == 'M' ||g[0] == 'm')
{
cout << "Enter radians - ";
degrees = radians * (180.0 / M_PI);
cout << "Radians -> Degrees says " << degrees << " degrees" << endl;
}
else if (g[0] == 'N' ||g[0] == 'n')
{
cout << "Enter degrees - ";
cin >> degrees;
radians = degrees * (M_PI / 180.0);
}
setcolor(7);
}```
But now I have problems with the program termination and case 7(trigonometry)
This is the program restart or quit code
Code:
```void Program::RorQ() //Gives user the option to restart or quit
{
C.exitRorQ = 1;
while(C.exitRorQ == 1)
{
clrscr();
cout << "(r) restart or (q) quit" <<endl;
cout << ">";
cin  >> C.rq[1];

if (C.rq[1] == 'r')
C.exitRorQ = 0;
else if (C.rq[1] == 'q')
{
C.exitRorQ = 0;
EXIT();
}
else
{
cout << "Thats not a choice... Please rechoose" << endl;
}
}
}```
And this is the Case7
Code:
```void Program::Case7()
{
setcolor(12);
cout << "Enter angle theta (radians) - ";
Sine = sin (a);
Cosine = cos (a);
Tangent = tan (a);
Arctan = atan (a);
Arccos = acos (a);
Arcsine = asin (a);
cout << "\nSine theta is " << Sine;
cout << "\nCos theta is " << Cosine;
cout << "\nTangent theta is " << Tangent;
cout << "\nInverse Sine(Arcsine) theta is " << Arcsine;
cout << "\nInverse Cos(Arccos) theta is " << Arccos;
cout << "\nInverse Tan(Arctan) theta is " << Arctan;
cout << "\n";
setcolor(7);
Sleep(3000);
}
.....
.....
case 7:
OMGDOIT.Case7();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;```
The restart or quit option works on all cases BUT this..If I try twice both r and q quit the program...

11. What is the code after the break on
Code:
`case 7: ...`
--
Mats

12. Code:
```case 1:
OMGDOIT.Case1();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 2:
OMGDOIT.Case2();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 3:
OMGDOIT.Case3();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 4:
OMGDOIT.Case4();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 5:
OMGDOIT.Case5();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 6:
OMGDOIT.Case6();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
break;
case 7:
OMGDOIT.Case7();
OMGDOIT.TerminationPrevention();
OMGDOIT.RorQ();
case 8:
C.exit = 0;
break;
default:
cout << "Enter a number in the list\n";
break;```

13. And what happens after the end of the switch?

[I'd also say that you don't need to have exitRorQ as a class member (or member of struct - not sure which it is from the context I can see) - it would make more sense to have that as a local variable - same applies to rq.]

--
Mats

14. Code:
```         default:
cout << "Enter a number in the list\n";
break;
}
clrscr();
}

return 0;
}```
This is what happens

15. And I take it that after clrscr, the brace is for some kind of while/for-loop - what is the condition that exits the loop?

--
Mats