int get_input (int *firstTerm, int *secondTerm, int *thirdTerm,
int *fourthTerm, int *fifthTerm, int *sixthTerm);
/* ... */
int main (void)
{
/* ... */
get_input (&fourthTerm, &fifthTerm, &sixthTerm);
If you were the compiler and the programmer told you to expect six arguments and the programmer only gave 3, would you be confused?
void get_input (int *firstTerm, int *secondTerm, int *thirdTerm)
{
/* ... */
}
void get_input (int *fourthTerm, int *fifthTerm, int *sixthTerm)
{
/* ... */
} And then later the programmer defined the exact same function twice. Okay, compiler, which one does s/he mean?
float avg_fee (float avg_fee);
/* ... */
void avg_fee (int termFee, int termFee2, float *avg) Then told you to expect one thing and gave you another?
I don't know. I'd listen to the compiler, which ought to be providing plenty of feedback, 'cuz I'd stop there but I think a compiler has more patience at reading this code than the programmer.
[edit]
At risk of having completely done your assignment...
#include <stdio.h>
#define UNIT_FEE 12
void get_input(int *a, int *b, int *c)
{
printf ("Please input the number of units (ex 10/12/10): ");
scanf ("%d/%d/%d", a, b, c);
}
int add(int a, int b, int c)
{
return (a + b * c) * UNIT_FEE;
}
float average(int a, int b)
{
return (a + b) / 2.0F;
}
void print(float avg_fee)
{
printf ("The average fee is: $%.2f\n", avg_fee);
}
int main (void)
{
int first, second, third, total1, fourth, fifth, sixth, total2;
float avg;
get_input(&first, &second, &third);
total1 = add(first, second, third);
get_input(&fourth, &fifth, &sixth);
total2 = add(fourth, fifth, sixth);
avg = average(total1, total2);
print(avg);
return 0;
}
/* my output
Please input the number of units (ex 10/12/10): 20/15/30
Please input the number of units (ex 10/12/10): 5/6/9
The average fee is: $3174.00
*/
[/edit]
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314