Percentage = (number correct / total questions) * 100
So you need to know the total questions (which you do, it is 'p') and the total correct answers. Whether or not an answer is correct can be found by comparing "answer" to "user" for each question.
For a beginner I think the tricky bit would be handling the float values correctly, and handling conversions float/int. In your code:
if (answer == user)
num_correct = num_correct + 1; // or num_correct++; if you prefer
answer is a float and x,y are ints. This will just calculate the integer part of x/y. E.g.
15 / 4
We know it's 3.75. If we rounded it we'd get 4. C will give you 3 -- just the int part of the result. It doesn't matter that the lhs of the assignment is a float, what matters is the types in the expression.
In any case - you need to think about how to check the answer is right when the answer is a float. You can't use a straight "==":
If the question is 2 / 3, and the user writes 0.66667, are they right? How close does the value have to be to be correct?
If the question is 61 / 10, and the user writes 6.1, are they right? It is not possible to represent 6.1 exactly in C's floating point representation (much like we can't write 2/3 exactly in decimal), so "==" will fail.
You'll need to decide how accurate the user's answer must be and test that the answer given is within that accuracy tolerance.
Your program will occasionally divide by 0, since your rand expression can generate 0. With floats, you'll get a defined value back -- but with ints, I think it's undefined (could crash your program). In any case, I think it's impossible for the user to get the question right So you should avoid asking the user this: perhaps a loop to keep regenerating num2 until it's not 0 if op is divide.