Homework in class is to write a arithmetic of 30 100 or less, which requires integers and arithmetic symbols to be randomly generated. Get the title first think about using the RAND function to produce integers in the output topic.
Program code:
#include <iostream>
using namespace Std;
void Main ()
{
int a,b,i,c;
for (i=0;i<30;i++)
{
A=rand ()%100+1;
B=rand ()%100+1;
C=rand ()%4+1;
if (c==1) cout<< "(" <<i+1<< ")" <<a<< "+" <<b<< "=" <<endl;
if (c==2) cout<< "(" <<i+1<< ")" <<a<< "-" <<b<< "=" <<endl;
if (c==3) cout<< "(" <<i+1<< ")" <<a<< "*" <<b<< "=" <<endl;
if (c==4) cout<< "(" <<i+1<< ")" <<a<< "/" <<b<< "=" <<endl;
}
}
Operation Result:
(1) 42*68=
(2) 1+70=
(3) 79*59=
(4) 65-6 =
(5) 82-28 =
(6) 92*96=
(7) 28/37=
(8) 5-3 =
(9) 93-83 =
(10) 17/19=
(11) 48/27=
(12) 39+70=
(13) 68/100=
(14) 95/4=
(15) 23-34 =
(16) 65/42=
(17) 54/69=
(18) 45-63 =
(19) 38/60=
(20) 42*30=
(21) 17*36=
(22) 43*89=
(23) 41+43=
(24) 49-47 =
(25) 91*30=
(26) 51-7 =
(27) 94-49 =
(28) 24*85=
(29) 57*41=
(30) 77+32=
Please press any key to continue ...
Cause: In class, there is no thought that the method of randomly generating operational symbols does not fulfill the requirement successfully.
The first section of the classroom summary