#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char* argv[])
{
int i,j,k,sum;
for (int t = 0;t<30;t++)
{
i = rand ()%50;
j = rand ()%50;
K = rand ()%4;
Switch (k)
{
Case 0:
sum = i+j;
printf ("Problem%d:", t+1);
printf ("%d+%d=%d\n", i,j,sum);
Break
Case 1:
if (I<J)
{
t = t-1;
Break
}
Else
{
sum = i-j;
printf ("Problem%d:", t+1);
printf ("%d-%d=%d\n", i,j,sum);
Break
}
Case 2:
sum = i*j;
printf ("Problem%d:", t+1);
printf ("%d*%d=%d\n", i,j,sum);
Break
Case 3:
sum = i/j;
printf ("Problem%d:", t+1);
printf ("%d/%d=%d\n", i,j,sum);
Break
Default
printf ("Error! \ n ");
Break
}
}
return 0;
}
Here, the answer to the operation is output directly on the screen, if you want to put the answer to the end, just create an array of integers sum[30], and the answer to each question there, the final output,
Here no more one by one details.
About the modification of 30 arithmetic (modify subtraction to make it minuend greater than the meiosis)