#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?

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

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.

This question has already been answered. Start a new discussion instead.