//the following two lines must not be changed, and will be explained in future weeks
#include
#include
//This function represents addition
int addition(int op1, int op2){
//you must fill in this function so that it adds the op1 and op2 and returns the result
}
//Create a function for subtraction that is named "subtraction", takes two ints, and returns the difference. (You should subtract the SECOND number from the FIRST)
//Create a function for multiplication that is named "multiplication", takes two ints, and returns the product.
//Create a function for division that is named "division", takes two ints, and returns the quotient. (You should divide the first number by the second number. Keep in mind we are using integer division, so all answers will be automatically rounded down.)
//NOTE: you cannot test your code until you have created the subtraction, multiplication, and division functions (though they do not need to work).
//DO NOT CHANGE ANY CODE PAST THIS POINT.
//ALL OF THE FOLLOWING CODE WILL BE EXPLAINED IN FUTURE WEEKS.
int main(int argc, char* argv[]){
int i;
for(i=0;i<15;i++){
int operation=rand()%4;
int op1s[] = {63,4,83,57,28,84,2,57,982,236};
int op2s[] = {27,24,78,3,5,7,8,2,4,78};
int op1=op1s[rand()%10];
int op2=op2s[rand()%10];
switch(operation){
case 0:
printf("%i+%i=%i\n",op1,op2,addition(op1,op2));
break;
case 1:
printf("%i-%i=%i\n",op1,op2,subtraction(op1,op2));
break;
case 2:
printf("%i*%i=%i\n",op1,op2,multiplication(op1,op2));
break;
case 3:
printf("%i/%i=%i\n",op1,op2,division(op1,op2));
break;
}
}
return 0;
}