Source code:
# Include <stdio. h>
# Include <stdlib. h>
Int main ()
{
Int I, A, B, U, V, c, d, g, h, X, Y, m, n = 0, Right = 0, wrong = 0;
Printf ("Hello! Welcome to the online Q & A \ n ");
For (I = 0; I <10; I ++)
{
A = rand () % (100-51 + 1) + 51;
B = rand () % (50-10 + 1) + 10;
G = rand () % (20-0 + 1) + 0;
H = rand () % (9-1 + 1) + 1;
{
Printf ("Please select question type: \ n ");
Printf ("Add 1 \ n ");
Printf ("Subtract 2 \ n ");
Printf ("multiplication, please input 3 \ n ");
Printf ("Enter 4 \ n Division ");
Scanf ("% d", & M );
Printf ("\ t % d.", I + 1 );
If (M = 1)
{
Printf ("\ t % d + % d =", a, B );
Scanf ("% d", & C );
If (a + B = C)
{
Printf ("\ t answer correct \ n ");
Right ++;
}
Else
{
Printf ("\ t answer error \ n ");
Wrong ++;
}
}
If (M = 2)
{
Printf ("\ t % d-% d =", a, B );
Scanf ("% d", & D );
If (a-B = D)
{
Printf ("\ t answer correct \ n ");
Right ++;
}
Else
{
Printf ("\ t answer error \ n ");
Wrong ++;
}
}
If (M = 3)
{
Printf ("\ t % d * % d =", g, h );
Scanf ("% d", & X );
If (G * H = X)
{
Printf ("\ t answer correct \ n ");
Right ++;
}
Else
{
Printf ("\ t answer error \ n ");
Wrong ++;
}
}
If (M = 4)
{
While (n <1000)
{
U = rand () % (20-0 + 0) + 0;
V = rand () % (9-1 + 1) + 1;
If (U % v = 0)
{
Printf ("\ t % d/% d =", U, V );
Scanf ("% d", & Y );
If (U/V = y)
{
Printf ("\ t answer correct \ n ");
Right ++;
}
Else
{
Printf ("\ t answer error \ n ");
Wrong ++;
}
Break;
}
Else
N ++;
}
}
}
}
Printf ("Congratulations! \ N ");
Printf ("Total number of answers: % d \ n", I );
Printf ("correct count: % d \ n", right );
Printf ("error count: % d \ n", wrong );
}
Running result:
(For example, 10 articles)
Four arithmetic online answers