#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>

int numbergen(int&); //initializes number generator function less than 9

int main(void)
{
	int number1=0;
	int number2=0;
	int answer=0;
	int userAnswer=0;
	int totalQuestions=0;
	int countWrong=0;
	int countCorrect=0;

	srand( time(NULL));

	printf( "Welcome to the Multiplication tester, enter -1 to quit! " );
		
	while ( userAnswer != -1 )
	{ //start while loop for quiz
		
		printf("\nWhat is %d multiplied by %d?\n",numbergen(number1), numbergen(number2));
		scanf( "%d", &userAnswer );
		answer=number1*number2;
		printf("answer is %d\n", answer);
		while (userAnswer != answer)
		{//start while
			printf("Try again!");
				scanf("%d", &userAnswer);
				++countWrong;//used to determine grade at the end(I thought this would be cool to do)
					++totalQuestions;//used to determine grade at the end(I thought this would be cool to do)
			}//end while
		if (userAnswer == answer )
		{//start if
			printf("Very Good!");
			++countCorrect;//used to determine grade at the end(I thought this would be cool to do)
				++totalQuestions;//used to determine grade at the end(I thought this would be cool to do)
		}//end if
		
	}//end while loop
	if (answer = -1)
	{
		printf("You got %d Wrong and %d Correct!", countWrong, countCorrect);
		printf("you got a %d!", countCorrect/totalQuestions);
	}
	getchar();
}//end main

int numbergen(int& Fnumber)
{
	Fnumber = 1+(rand()%9); //generates a random number 1-9
	return Fnumber;
}//end number generator