//programming language "C" ...
#include <stdio.h>//for all xD
#include <time.h> //for random
#include <string.h> //only 2 be sure
#include <stdlib.h>//for some shit
int main()
{
srand ((unsigned)time(NULL));
int max; //maximalnumber
int maxtasks;//how many tasks
int tasks;//only int to count the tasks
int right = 0;//rightanswers
int wrong = 0;//wronganswers
int d;
printf("How many exercises do you want to have?\n");
scanf("%i",&maxtasks);
printf("Put in the max of your number: ");
scanf("%i",&max);
int a = rand()%max;
int b = rand()%max;
int c = a + b;
printf("%i + %i = ",a,b);
scanf("%i",&d);
if (d == c)
{
printf("right\n");
}
else
{
printf("wrong\n");
}
for (tasks=1;tasks < maxtasks;tasks++)
{
a = rand()%max;
b = rand()%max;
c = a + b;
printf("%i + %i = ",a,b);
scanf("%i",&d);
if (d == c)
{
printf("right\n");
right += 1;
}
else
{
printf("wrong\n");
wrong += 1;
}
}
double percentright = 100 / maxtasks * right;
printf("You have %lf percent right\n",percentright);
return 0;
}
You' re using int multiply and divide where you should be using double for youe calculation.