Thanks for the replies. I am reading everyone and understanding perfectly. Here is a function that passes too values (ANSWERS function). I know I should comment out, but it gets too unorganized in notepad with the editing. This function just adds two similar numbers together and tells you if you are right or wrong. It keeps track of all the right and wrong answers and tells you how many you got of each. I ask what you want to add too: for example if you pick 3, it will add 1+1, 2+2, 3+3 and tells you how many you got right and wrong. It works perfectly until you get to how many you got right and wrong, and it tells you 0. I know the problem is passing the values of right and wrong back to the main(). It isnt modifying the values. So I guess my question would be is: how do you pass 2 values back. Thanks again for the help. Im learning a lot here
Code:
#include <stdio.h>
int topnumber(void);
int answers(int number, int right, int wrong);
int main(void)
{
int right = 0, wrong = 0, number, answer;
printf("This is an addition drill program.\n");
number = topnumber();
answer = answers(number, right, wrong);
printf("You got %d Right!...and %d Wrong!", right, wrong);
return 0;
}
int topnumber(number)
{
printf("What number do you want to add to? ");
scanf("%d", &number);
return number;
}
int answers(int number, int wrong, int right)
{
int i, answer;
for (i = number; i > 0; i--)
{
printf("What is %d + %d\n", i, i);
scanf("%d", &answer);
if(answer == i + i)
{
printf("Right!\n");
right++;
}
else
{
printf("Wrong!\n");
wrong++;
}
}
return right, wrong;
}