Multiplying two random numbers

So this is a program to test elementary multiplication tables but the line where it says a * b = answer it says it cannot do because it has to be one value. How do I approach this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//Alex Wild
//Engr 21
//October 31st, 2011
//Multiplication Teacher

#include <cmath>
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
	int main ()
{
	char again;
	int a, b, answer, guess; //Random numbers, answer, and user guess
	
	cout << "Welcome to the Multiplication Machine." << endl;

	again='Y';
	while ((again=='y') || (again=='Y'))
	{
		srand ( time(NULL) );
		a = rand() % 10;
		b = rand() % 10;

		cout << "What's " << a << "x" << b << "?";
			cin >> guess;

		a * b = answer;

		while (answer != guess){
			cout << "No. Please try again" << endl;
			cout << "What's " << a << "x" << b << "?";
			cin >> guess;}
		if (answer == guess)
			cout << "Correct. Try another (y/n)?";
			cin >> again;
	}

	return 0;
}
Last edited on
use answer = a*b; instead of a * b = answer;

= operator assigns value of right expression to left one.
Topic archived. No new replies allowed.