I am trying to write a simple program where the user enters a number and the computer tries to guess it. I wanted to make it a bit smarter, so that the program knows if its guess it higher or lower than what the users number are, and make the next guess with using that information

But it dont work.

Could someone please help me out a bit?

Code:
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main() 
{
    int myRandNo;
    int compNo = 50;
    int randNo = 0;
    
    cout << "Welcome to the guessing game" << endl;
    cout << "Please enter a number between 1 and 100: ";
    cin >> myRandNo;
    
    while (compNo != myRandNo)
    {
          //seed the rand
          srand(time(0));
          
          //guess was to low
          if (compNo < myRandNo)
          {
              randNo = rand();
              compNo = (randNo % 100) + currentGuess;
              //cout << compNo << "CompNo is smallest" << endl;
          }
          
          //guess was to high
           if (compNo > myRandNo)
          {
              randNo = rand();
              compNo = (randNo % currentGuess) + 1;
              //cout <<compNo  << "CompNo is biggest" << endl;
          }
          
    //cout <<"wrong" << endl;
             
    }
    
    cout <<"right";
     
    system("pause");
    return 0;
}
Thanks