I took the liberty to patch it a little.
Compacted the variables a tad and fixed your string in the first fprintf. Also, when checking something (like if 5 is equal to 2+3), you should use == as = always sets stuff but doesn't check if something's correct or not. Watch out which variables you use, some of them were never declared before.
Actually, here it is in C++, not C.
#include <iostream>
#include <time>
int main()
{
// random seeding and variable declaration
srand(time(NULL));
int x = 1+rand()%10;
int y = 1+rand()%10;
// asking for user input
printf("Add these two numbers together: %d and %d\n", x, y);
int z;
std::cin >> z;
int answer = 1+(rand()%3);
// checking the user input
if (z == x+y)
if (answer == 1)
printf("Correct!\n");
else
if (answer == 2)
printf("Congrats!\n");
else
printf("That's the right answer!\n");
else /*if (z != x+y)*/ // commented out because it is always either true or false, no need to check it again
printf("Sorry, that's incorrect.\n");
return 0;
}
Feel free to ask for explanations if needed.