Nov 7, 2008 at 5:55am UTC
Can anyone correct this please?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
long num,result,pow;
cout<<"enter the number whose reult you have to find out" ;
cin>>num;
cout<<"enter the power " ;
cin>>pow;
result=(num)^pow;
cout<<"the result is " ;
cout<<result;
getch();}
Last edited on Nov 7, 2008 at 5:57am UTC
Nov 7, 2008 at 8:24am UTC
C++ doesn't have a ^ operator. You have to use the pow() function from the math.h class.
Nov 7, 2008 at 8:28am UTC
So you want to write your own version of pow()?
You can take the num-value und multiply it with itself as many times as the pow-value... does this help you out?
Greetz DG
Nov 7, 2008 at 12:13pm UTC
ankitsikka1992, this is the problem with ur code:
result=(num)^pow;
you can write it like this:
result=pow(num,pow)
if u want to create ur own version, it is as DarkGecko78 says, I did it once, using for()
Last edited on Nov 7, 2008 at 12:14pm UTC
Nov 7, 2008 at 1:40pm UTC
@ Hypersion
C++ has a ^ operator, its meaning is xor
Nov 8, 2008 at 1:19am UTC
Bazzy,
Your right, I should have stated that ^ means xor not power.