You are using a version without Ads of this website. Please, consider donating:

### error message "ID RETURNED 1 EXIT STATUS

closed account (9G6fSL3A)
Trying to compile this however Im getting a message "ID RETURNED 1 EXIT STATUS" Does anybody know how to fix my code to solve this problem?

 ``1234567`` `````` int pow2(int n){   int result=1;   for (int i=0;i
It's not `ID`, it is `ld`
http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1

> Does anybody know how to fix my code to solve this problem?

Write `main()`

 ``1234567891011121314`` `````` int pow2(int n){   int result=1;   for (int i=0;i int main() { std::cout << pow2(17) << '\n' ; }``````
closed account (9G6fSL3A)
It gives an answer for this one

 ``1234567891011121314`` ``````int pow2(int n){ int result=1; for (int i=0;i int main() { std::cout << pow2(29) << '\n' ; }``````

But but for this:

 ``1234567891011121314`` ``````int pow2(int n){ int result=1; for (int i=0;i int main() { std::cout << pow2(30) << '\n' ; }``````

Whenever I go over power 30 i get 0 as answer. Any way to change this?
Last edited on
`pow2()` returns an `int`; it can't return a value that is bigger than the largest value that an `int` can represent.

Try this:

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include #include unsigned int pow2( unsigned int n ) { if( n >= std::numeric_limits::digits ) return 0 ; unsigned int result = 1 ; // return result << n ; for( unsigned int i=0; i 0 ) std::cout << "2^" << n << " == " << result << '\n' ; else { std::cerr << "the number 2^" << n << " is too big to be represented by an unsigned int\n" ; return 0 ; } } }``````

And then, replace `unsigned int` with `unsigned long long` and try it again: http://ideone.com/9R08mx
i've already told him this in another one of his posts.

OP, look at this table:
http://www.cplusplus.com/doc/tutorial/variables/
Topic archived. No new replies allowed.