20150324 exercise a program with four arithmetic questions, and 20150324 arithmetic operations
Source code:
# Include <stdio. h>
# Include <stdlib. h>
Main ()
{Int a, B, op, OS;
Printf ("[do not worry about my learning when I practice every lesson] \ n ");
Aq1: printf ("select the algorithm you want to challenge \ n ");
Printf ("1. Addition 2. subtraction 3. Multiplication 4. Division \ n ");
Scanf ("% d", & op );
Switch (op)
{
Aq: case 1:
A = rand (); B = rand ();
Printf ("Question: % d + % d =? \ N ", a, B );
Printf ("1. view the answer 2. Make the next question \ n ");
Scanf ("% d", & OS );
If (OS = 1)
{Printf ("% d + % d = % d \ n", a, B, a + B );
Goto aq1;
}
Else
Goto aq;
Break;
At: case 2: a = rand (); B = rand ();
Printf ("Question: % d-% d =? \ N ", a, B );
Printf ("1. view the answer 2. Make the next question \ n ");
Scanf ("% d", & OS );
If (OS = 1)
{Printf ("% d-% d = % d \ n", a, B, a-B );
Goto aq1;
}
Else
Goto;
Break;
Aq2: case 3:
A = rand (); B = rand ();
Printf ("Question: % d * % d =? \ N ", a, B );
Printf ("1. view the answer 2. Make the next question \ n ");
Scanf ("% d", & OS );
If (OS = 1)
{Printf ("% d * % d = % d \ n", a, B, a * B );
Goto aq1;
}
Else
Goto aq2;
Aq3: case 4:
A = rand (); B = rand ();
Printf ("Question: % d/% d =? \ N ", a, B );
Printf ("1. view the answer 2. Make the next question \ n ");
Scanf ("% d", & OS );
If (OS = 1)
{Printf ("% d/% d = % d \ n", a, B, a/B );
Goto aq1;
}
Else
Goto aq3;
Break;
}
}
Summary:
1. rand () does not actually implement srand.
2. Excessive goto use causes damage to the overall structure
3. No rand range is set.