Hi guys,

I need to measure the time elapsed during the code below is being executed using clock() function. But I don't know how.

#include <iostream>
#include <ctime>
using namespace std;
long int IterativePower(int x, int n)
{
    int result = 1;
    if (n < 1)
        return result;
    while(n >= 1)
    {
        result = result * x;
        n--;
    }
        return result;
}
int main()
{
    int x, n; cin >> x >> n;
    cout << IterativePower(x, n);
        return 0;
}

Thanks in advance.