This is the feature in question. The specified variable count1. Before the return count1;function is mapped to reset count1 to 1 or 2. The result of the final line coutis n lines, where n = the number of attempts, including the correct answer. Each line displays a number, which is 1 more than the line below, to count1= either 1 or 2. I could not set the template to which it will be finally output.
The questions themselves are just placeholders.
What is happening on earth?
Note. I am a very new programmer, and I know that there are more efficient ways to do what I do that I did not recognize. I am open to suggestions, but my understanding of these suggestions will most likely be hampered by my unfamiliarity with C ++
int q1(int count1)
{
using namespace std;
if (count1 <= 3)
{
cout << "What is 2+2 \n";
double a1;
cin >> a1;
if (a1 == 4)
{
cout << "Yup. You know what 2+2 is. \n\n";
}
else
{
wrong();
q1(++count1);
}
}
else
{
cout << "You have used all three tries. Next question. \n\n";
++count1;
}
cout << count1 << "\n";
return count1;
}
cout :
5
4
3
2
\n
5432
EDIT:
, - , , , .
q1(++count1) count1 = q1(++count1);
, , . ?