@Mich
Thank you very much , I tested my game thoroughly, but then due to the recursion process I was unable to make few decision.
I then implemented only negamax(without alpha beta pruning).
and now it works, however, now I am stuck with the alpha beta pruning part.
my program moves from left to right and then evaluates the positions.
The game is fully working with only negamax.
but I want to learn, addition of alpha beta algorithms and then higher algorithms.
The error my program was making was not seeing any win for itself or for the opponent.
kindly help me with it if possible.
here is the code fully working tic tac toe with AI.
CODE