> else if (g[0] == 'N' || 'n')
I thought we explained this one already in another thread.

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

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

10-01-2007

robatino

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.

10-01-2007

SVXX

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

10-02-2007

Salem

> 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.

10-02-2007

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

10-02-2007

robatino

Quote:

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

10-02-2007

matsp

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

10-02-2007

SVXX

Well..I changed the stuff and added a separate Radians Degrees Conversion part instead

[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

10-02-2007

SVXX

Code:

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

return 0;
}

This is what happens

10-02-2007

matsp

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?