Assistance needed with program!!

closed account (EhMoizwU)
Hi this is my first year studying c++ and I really need help with a program
[b]Here is what the program should be:


Welcome to Multiplication Practice Software.
This program will help you practice multiplication by
presenting you with randomly generated practice
problems at different level of difficulty. The
difficulty is determined by the number of digits in
the multiplication. You can specify the initial
number of digits. The program will also keep track
of your progress. At the end of each session, you
may choose to continue or not.
Please enter the level of difficulty (1 and up): 1
-----------------------------------
Difficulty Level = 1
8 | 2 * 4 = 8
Correct!
35 | 7 * 5 = 35
Correct!
10 | 2 * 5 = 10
Correct!
49 | 7 * 7 = 49
Correct!
3 | 3 * 1 = 3
Correct!
End of one session. 100% correct.
Excellent! You are ready for the next level of difficulty.
Do you want to quit? n
-----------------------------------
Difficulty Level = 2
589 | 19 * 31 = 589
Correct!
992 | 62 * 16 = 992
Correct!
5152 | 92 * 56 = 5112
Incorrect answer. Try again.
5152 | 92 * 56 = 5152
Correct!
1768 | 68 * 26 = 1766
Incorrect answer. Try again.
1768 | 68 * 26 = 1766
Incorrect answer. Try again.
1768 | 68 * 26 = 1766
Incorrect answer. The answer is: 1768. Let's move on.
527 | 31 * 17 = 527
Correct!
End of one session. 50% correct.
You need to practice more. Please seek help from the instructor.
Do you want to quit? n
-----------------------------------
Difficulty Level = 2
1692 | 94 * 18 = 1692
Correct!
6290 | 85 * 74 = 6288
Incorrect answer. Try again.
6290 | 85 * 74 = 6290
Correct!
735 | 35 * 21 = 735
Correct!
2736 | 76 * 36 = 2736
Correct!
3422 | 59 * 58 = 3422
Correct!
End of one session. 83.3333% correct.
Good job, continue with more practice.
Do you want to quit? y


Now this is what I have right now:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[tt]#include<cstdio>

#include<iostream>

#include <cmath>

using namespace std;

const int QUESTIONS = 5;

int difficulty_level;



//function to generate a question and return two numbers
//call by reference

void two_numbers(int low,int high,int& num1,int& num2); //one question
bool ask_question(int low,int high,int& no_correct,int& no_uncorrect); //set of questions


//what else?
//function to generate a random number

int random (int low, int high);
//function to get low and high provided difficulty level
void get_bounds(int deff,int& low, int& high);

int main()
{
    
    //enter difficulty level;
    cout<<"Enter difficulty level";
    cin>>difficulty_level;
    cout<<endl;



    
    //cin>>difficulty level;
    //ask a question 5 times???//use a for loop?
    
 
    


system("pause");
return 0;
}

void two_numbers(int low,int high,int& num1,int& num2)
{
     num1=random(low,high);
     num2=random(low,high);
    
}     

bool ask_question(int low,int high,int& no_correct,int& no_uncorrect)
{
  int num1,num2;
  bool yes;
  //calculate two numbers
  two_numbers(low,high,num1,num2);
  cout<<num1<<"*"<<num2<<"?:";
  cin>>enter;

  //check if the number enter by the user is right or wrong
  if(enter==right)
  {    cout<<"correct!"<<endl;
      no_correct++;
      yes=true;
  }
  else
  {
      no_incorrect++;
  }
  
}
//function to generate a random number between low and high
int random(int low,int high)
{
    return rand()&(high-low)+low;
}
void get_bounds (int diff,int& low,int& high);
{
     low=static_cast<int>(pow(10.0,(diff=1)));
     high=static_cast<int>(pow(10.0,(diff=1)));

I' getting an error on "cin>>enter;"
And if anyone can help me finish this program please help!!
Any help is appreciated, Thanks!
Last edited on
You haven't identified the problem in your code? How can we post a solution when you don't have a problem to fix?
Yea whats problem and try to use the [code ][/code ] Things so we can see where you code is easyer.
closed account (EhMoizwU)
can anyone help?
If you read the error reports of your compiler you should find that 'enter' wasn't declared...

PS: The title of your question should be the topic of it, not how your problem is urgent

(edited: sorry, typed 'error' istead of 'enter')
Last edited on
closed account (EhMoizwU)
"In function `bool ask_question(int, int, int&, int&)': " is the error im getting
That's not the error, that's the report telling you the function in which the error is contained.

Like Bazzy said, the variable 'enter' was not declared within your code. When you initiate num1 and num2 at the beginning of that function, initialize enter along with it. Also, change the two times no_uncorrect occurs in your code(in the function header and protocol for ask_question) to no_incorrect as you use it under the misspelled name twice, lines 19 and 58, and once under the right name.

Can't help you with completing the code, however, as I am a C++ nub.
The variable 'right' wasn't declared too.
I suggest you using 'num1*num2' instead of declaring a new variable there.
Topic archived. No new replies allowed.