even number program in c++ using for loop stack overflow
int func(int x, int y){
if(y>x && x>0){
int res = x;
for(int i = x+1 ; i <= y ; i+=1){
if(i%2==0)
res += i;
else
res *= i;
}
return res;
}
return -1;
}