How to make a program to enter the base and its power and print its reult???

closed account (1hfjLyTq)
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
C++ doesn't have a ^ operator. You have to use the pow() function from the math.h class.

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
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
@ Hypersion
C++ has a ^ operator, its meaning is xor
Bazzy,

Your right, I should have stated that ^ means xor not power.
Topic archived. No new replies allowed.