You're using num1 and num2 before initialising them. I suggest initialising them to the return value of rand() % 20.
Yes, you need a do .. while rather than a while loop here.
I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
Visit my website for lots of associated C programming resources. https://github.com/MalcolmMcLean