#include <iostream>
using namespace std;

typedef unsigned short ushort;
typedef unsigned long ulong;

ulong power(ushort, ushort);

int main()
{
	ushort x,y;
	ulong z;

	cin>> x; cin>> y;
	
	z=power(x,y);
	cout<< z;

	return 0;
}

ulong power(ushort i, ushort j)
{
	if (j==1) return i;
	[B]else return (i * power(i, j-1)); [/B] 
}

cant seem to understand the highlighted part. i mean, the function isnt yet finished and i is already getting some value of it. it works correctly, but could someone explain the way it actually computes?

Actually You are calling a recursive function ....
it will continue until value of j becomes 1

ah that
i guess it is out of my understanding range for the time given ^^

"i" is actually the number and "j" is its power.

like i=4 and j=4 so it will become 4pow4 = 256

i think know u understand

like i=4 and j=4 so it will become 4pow4 = 256

yes but as my highlighted place takes an input of 2 ints so isnt it more like (4 * power(4,4-1))

actually Your function is calling again and again . It is a concept of recursive function in which each values are stored in memory after each call until termination.

with some help of the local irc gang understood it

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.