why this code is giving me runtime error?

What's the error? Something's wrong with my dev C compiler, so I can't even compile.

And do you even need all those references?

Code seems to work fine on my Code::Blocks 12.11 with Cygwin GCC compiler.

Yeah, the problem's on my end. I can't compile any Cs or Cpps. Which is why I was asking OP what the error is.

@ tinstaafl it is also working fine on my dev-c++ but why it giving RTE on ideone?

@ tinstaafl it is also working fine on my dev-c++ but why it giving RTE on ideone?

I suspect you're not giving the Ideone sufficient input to work with. Click the "upload with new input" button and add this:

5 1 2 3 4 5

There should be no errors and the output will be:

3
9
27
81
243

@deceptikon i also think so but i remember a lot of times i got 'success' without any i/p.

In those cases either the program didn't expect input, or your code used reasonable default values. Did you try what I suggested?

@deceptikon i have given i/p yesterday and it works .
and yes,you are right. i declared 'n' aand 'k' global and i got success.
thanks.

i declared 'n' aand 'k' global and i got success.

That means they're defaulted to 0 instead of given some random value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.