# invalid operands to binary ^ ?

• 09-13-2005
seal
invalid operands to binary ^ ?
What is wrong with this? cant figure it out... perhaps the square sign i'm using is the wrong square sign?

Code:

```#include <stdio.h> int main () {     double m;     double n;     double side1;     double side2;     double hypo;         printf ("Enter the side of n\n");     scanf ("%lf", &n);     printf ("Now enter the side of m\n");     scanf ("%lf", &m);     side1 = m^2 - n^2;     printf ( "Side 1 is" );     printf ("%lf", side1); return 0 }```
the program isnt done, but i thought i check that 1st part, and keep getting the error

15 C:\Documents and Settings\Emir\Desktop\C\Class\triangle.c invalid operands to binary ^

?
• 09-13-2005
Thantos
^ is bitwise XOR not power

To correct it:
#include <math.h>
and use pow()
• 09-13-2005
seal
Quote:

Originally Posted by Thantos
^ is bitwise XOR not power

To correct it:
#include <math.h>
and use pow()

ok lemme try
• 09-13-2005
seal
how do i use the pow?

i did

Code:

`    side1 = m pow(2) - n pow(2);`
i dunno how to use pow :(
• 09-13-2005
cwr
From a maths point of view, I don't understand that code, but assuming you are using ^ to mean "power", then you wanted:
Code:

```#include <stdio.h> #include <math.h> int main () {     double m;     double n;     double side1;     double side2;     double hypo;     printf ("Enter the side of n\n");     scanf ("%lf", &n);     printf ("Now enter the side of m\n");     scanf ("%lf", &m);     side1 = pow(m, 2.0) - pow(n,2.0);     printf ( "Side 1 is" );     printf ("%lf", side1);     return 0; }```
The ^ operator has nothing to do with powers, it's the bitwise exlusive or operator.
• 09-13-2005
Thantos
Quote:

Originally Posted by seal
how do i use the pow?

i did

Code:

`    side1 = m pow(2) - n pow(2);`
i dunno how to use pow :(

• 09-13-2005
Salem
But I searched for 'pow' and all I got were a lot of cheesy references to the Batman TV series ;)
• 09-13-2005
seal
Quote:

Originally Posted by Thantos

last time i checked this was a msg board for programming, and it doesnt say no basic questions allowed
• 09-13-2005
seal
Quote:

Originally Posted by Salem
But I searched for 'pow' and all I got were a lot of cheesy references to the Batman TV series ;)

actually you would get alot of references to POW as in prisoner of war...
• 09-13-2005
seal
Quote:

Originally Posted by cwr
From a maths point of view, I don't understand that code, but assuming you are using ^ to mean "power", then you wanted:
Code:

```#include <stdio.h> #include <math.h> int main () {     double m;     double n;     double side1;     double side2;     double hypo;     printf ("Enter the side of n\n");     scanf ("%lf", &n);     printf ("Now enter the side of m\n");     scanf ("%lf", &m);     side1 = pow(m, 2.0) - pow(n,2.0);     printf ( "Side 1 is" );     printf ("%lf", side1);     return 0; }```
The ^ operator has nothing to do with powers, it's the bitwise exlusive or operator.

thx for showing me how to use pow () :)
• 09-13-2005
cbastard
Quote:

Originally Posted by seal
thx for showing me how to use pow () :)

Before googling try to use help function provided in your compiler.
you will get everything instantly.If help is not there in it.then best of luck for next time :D
• 09-13-2005
Thantos
Quote:

Originally Posted by seal
last time i checked this was a msg board for programming, and it doesnt say no basic questions allowed

Actually we do want you to do the work. There is a SEARCH feature on this message board and on google. Use them.

Quote:

Originally Posted by seal
actually you would get alot of references to POW as in prisoner of war...

only if you are stupid enough to just use "pow" as your search. If you notice my search had a lot more then just pow
• 09-13-2005
seal
Quote:

Originally Posted by Thantos
Actually we do want you to do the work. There is a SEARCH feature on this message board and on google. Use them.

only if you are stupid enough to just use "pow" as your search. If you notice my search had a lot more then just pow

i was comparing 'pow' to batman pow not the pow ()

could have told me how to use it and saved us alot of trouble but oh well, thx for the help that u've provided
• 09-13-2005
quzah
1) You obviously have no sense of humor.
2) You're apparently lazy, and would rather be given an answer than taught how to help yourself.
3) Lazy humorless people annoy me.

Quzah.
• 09-13-2005
Thantos
See salem was poking fun at me and being silly. Now I could have just told you exactly how to use pow but then what about next time? Hopefully now you'll know how to find the answer for yourself. Also considering that I gave you a link to a search page in which the very first result told you exactly what the fun did and how to use it, I think I did tell you how to use it.