Thanks to gratuitous, I got the program working. For anybody else who may be interested in trying their luck, here is the exact code:

Code:
#include <iostream>
#include <conio.h>
#include <cmath>


int main()
{
     long n = 1,i,j,flag,s,k;  //initializing
     long p = 3;               //replace 'p' to check for any other power


     while(1)                //loop till infinity
    {
        flag=0;k=pow(n,p);


        for(i=1;pow(i,p)<k;i++)         //looping first number
        {
            for(j=i+1;pow(i,p)+pow(j,p)<=k;j++) //looping second number
            {
              s=pow(i,p)+pow(j,p);
              if(s==k){flag++;}
              if(flag==2){break;}           //break out of loop if found
            }
            if(flag==2){break;}
        }
        if(flag==2){std::cout<<n;break;}  //print number if found and the program terminates
        n++;
     }
return 0;
}