Exponent program question because im getting some stupid error

So basically im making a program which ouputs the exponent of the exponent of a number

so basically, if you put in 5, it does 5^5^5

Heres my code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int main(){

	int number, answer=1,final,endanswer=1;

	cout<<"Please enter the number that you want its exponential twice!"<<endl;
	cin>>number;

	for(int counter=0; counter<number; counter++) {
		answer = answer * number;
	}
	cout<<number<<"To the power of"<<number<<" = "<<answer<<endl;
	final = answer;

	
	for(int counter=0; counter<number; counter++) {
		endanswer= final * endanswer;
	}

	cout<<number<<"To the power of"<<number<<"To the power of"<<number<< " = "<<endanswer<<endl;
	return 0;
}



I get the error "One or more multiply defined symbols found" and the error is at the 10th line, but theres nothing in the 10th line??

So please help me!

Thanks
Last edited on
counter is defined twice.
that doesnt change anything tbh, and I was getting the error before putting the second part, so basically before putting the second "for" loop
using devc++ and compiles just fine :) The awnser however isn't correct..
you're only finding the exponent once, you calculate 5^5 for example, then do this:

1
2
for(int counter=0; counter<number; counter++) {
		endanswer= final * endanswer;


which just multiplies the result of 5^5 by 5. The below code is correct but you need to do it twice, and remove the code shown above.

1
2
for(int counter=0; counter<number; counter++) {
		answer = answer * number;


As for the error you are getting I can only assume it is the compiler you are using...sorry
Topic archived. No new replies allowed.