Based on the original arithmetic, the true fractional operation (validation correctness) is supported in addition to integers.
One-out problem avoids repetition
Customizable number of quiz
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int num,i,k;
printf ("Please enter the number of questions:");
scanf ("%d", &num);
float Fa,fb,fc,fd,result;
k=0;
for (i=0; i<num; i++)
{
int Isint1=rand ()%2;
int Isint2=rand ()%2;
if (isint1==0)
{
Fa=rand ()%100+1;
}
Else
{
Fa=rand ()%100+1;
Fb=rand ()%100+1;
if (FA>FB)
FA=FB/FA;
Else
FA=FA/FB;
}
if (isint2==0)
{
Fc=rand ()%100+1;
}
Else
{
Fc=rand ()%100+1;
Fd=rand ()%100+1;
if (FC>FD)
FC=FD/FC;
Else
FC=FC/FD;
}
int op;
Op=rand ()%4;
Switch (OP)
{
Case 0:
{
printf ("%f +%f=", FA,FB);
scanf ("%f", &result);
if (result-(FA+FB) <0.000001)
k++;
Break
}
Case 1:
{
printf ("%f-%f=", FA,FB);
scanf ("%f", &result);
if (result-(FA-FB) <0.000001)
k++;
Break
}
Case 2:
{
printf ("%f *%f=", FA,FB);
scanf ("%f", &result);
if (result-(FA*FB) <0.000001)
k++;
Break
}
Case 3:
{
printf ("%f/%f=", FA,FB);
scanf ("%f", &result);
if (result-(FA/FB) <0.000001)
k++;
Break
}
}
}
printf ("You counted the right%d questions", k);
}
Arithmetic Advanced Edition