Learn how to divide your code into functions. It will help with this kind of stuff.
Anyway, I've written this type of program out a few times. The idea behind it is that the CPU player needs to have a high limit and a low limit. The limits start at some predetermined numbers. After that, they move dynamically depending upon the guess. If you guess a number, say 10, and it's too low, then you know that the number in question must be greater than 10. So assign 10 to your low limit. Simply put: low = guess; Same concept with the high limit.
It appears that you do this to some degree, but your guess doesn't appear to be based upon your limits:
Code:
compMin = guessNum;
compVar = (50 - compMin);
guessNum = (rand() % 50) + compVar;
Code:
compMax = guessNum;
guessNum = (rand() % compMax) + 1;
Why are you not using your max and min limits in your rand() call properly?