You've got a few holes in your program, such as functionality that it needs. Here's a quick one from me, compare and contrast, then try and find other ways to do it.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static void checkAnswer ( int userAnswer, int compAnswer )
{
if ( userAnswer == compAnswer )
printf ( "You answered correctly!\n" );
else
printf ( "Sorry, the answer was %d\n", compAnswer );
}
int main ( void )
{
int x, y, uAnswer;
srand ( (unsigned)time ( NULL ) );
do {
x = rand() % 12, y = rand() % 12;
printf ( "What is %d x %d? ", x, y );
(void)scanf ( "%d", &uAnswer );
while ( getchar() != (int)'\n' );
checkAnswer ( uAnswer, ( x * y ) );
printf ( "\nAnswer another? (y/n): " );
} while ( toupper ( getchar() ) == (int)'Y' );
return EXIT_SUCCESS;
}
-Prelude