No you cannot return more than one thing from a function. Neither can you, as other people have put it, return an array. What you do with arrays is pass them in, like this:
Code:
int menu (int *myarray, size_t size);
int myarray[] = { 0, /*principal */, 0 /* term */, 0 /* rate */ };
menu(myarray, 3);
Then menu would change the three values and when it returns those values are available in main(). The truth is, the variables never really left main() like they would at other times. You changed the variables through a pointer. You could also use multiple pointers for month, rate, and principle if you wanted.
But I think menu() has more problems than that.
Looking here:
Code:
switch (choice)
{
case 'a':
printf("What is the principal you wish to enter?:\n");
principal = getchar();
return principal;
break;
case 'b':
printf("What is the annual interest rate?:\n");
rate = getchar();
return rate;
break;
case 'c':
printf("How many months in which does the loan need to be paid?:\n");
months = getchar();
return months;
I see that you're asking the user for input on his loan, but none of that data is being read exactly. It's highly unlikely that the loan data will fit in the integer that getchar returns. Read here:
So unless the amounts are always ridiculously small... you know what, let's just admit
you need numbers.
Additionally, I think menu is responsible for far too much, or is at least poorly named. It should probably call at least one other function to calculate the loans and print them. I hope you're going in that direction and not trying to do everything in one function.
HTH
EDIT: You'll have to excuse me, it takes time to write posts, and sometimes things move along without me.
You would read input into a normal variable first and then do something like:
Code:
array[0] = principal;
array[1] = rate;
array[2] = months;
whiteflags.