Hello,
I am working on a program that asks the user to input an integer value. It then raises X to all the powers from 0 up to 5, using the user entered value.
For example, if the user entered 5 the output would be:
2 ^ 0 = 1
2 ^ 1 = 2
2 ^ 2 = 4
2 ^ 3 = 8
2 ^ 4 = 16
2 ^ 5 = 32
I have done this so far (Im pretty new to this stuff, so please dont completely blow me off):
Here is a list of errors that I receive, I was wondering if anyone would be able to help me out here, what show I try changing?Code:#include <iostream> int main() { int i; cin >> i; for (i=i; i>=0; i*i) { cout << i; cout << i << " ^ 0 = " << i ^ 0 << endl; cout << i << " ^ 1 = " << i ^ 1 << endl; cout << i << " ^ 2 = " << i ^ 2 << endl; cout << i << " ^ 3 = " << i ^ 3 << endl; cout << i << " ^ 4 = " << i ^ 4 << endl; cout << i << " ^ 5 = " << i ^ 5 << endl; } cout << endl; return 0; }
I will continue working on it, but input would be appreciated greatly!
Errors:
I will try stuff, but It would be great if you could give me some feedback.Code:powersof2.cpp: In function `int main()': powersof2.cpp:11: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:12: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:13: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:14: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:15: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:16: invalid operands `int' and `ostream & ()(ostream &)' to binary `operator <<' powersof2.cpp:17: warning: statement with no effect
Thank you!