#include <stdio.h>
#include <math.h>
void getTerms(void);
int getPattern(int* term1, int* term2, int* term4, int* term5);
void patternAdd(int* term1, int* term2, int* term5);
void patternMultiply(int* term1, int* term2, int* term5);
int term1;
int term2;
int term3;
int term4;
int term5;
int test1;
int test2;
int addval;
int multval;


int main(void)
{

getTerms();

if (getPattern(int term1*, int term2*, int term4*, int term5*) == 1)
 {
patternMultiply(int term1*, int term2*, int term5*);
}
else
{
patternAdd(int term1*, int term2*, int term5*);
}


return 0;
}

void getTerms(void)
{
int term1;
int term2;
int term3;
int term4;
int term5;

printf("The first 5 numbers of the series now: ");
scanf("%d %d %d %d %d", &term1, &term2, &term3, &term4, &term5);

return;
}



int getPattern(int term1*, int term2*, int term4*, int term5*)
int term5;

test1 = term2 / term1;
test2 = term5 / term4;

if (test1 == test2)
{
getPattern() = 1;
}
else
{
getPattern() = 0;
}

return getPattern();
}


void patternAdd(int term1*, int term2*, int term5*)
{
int addval;
int term1;
int term2;
int term5;

addval = term2 - term1;

printf("\nThe next 5 in the series are: %d %d %d %d %d\n", term5 + addval, term5 + 2 * addval, term5 + 3 * addval, term5 + 4 * addval, term5 + 5 * addval);

return 0;
}


void patternMultiply(int term1*, int term2*, int term5*)
{
int multval;
int term1;
int term2;
int term5;

multval = term2 / term1;

printf("\nThe next 5 in the series are: %d %d %d %d %d\n",term5 * multval, term5 * multval * multval, term5 * multval * multval, term5 * multval * multval * multval, term5 * multval * multval * multval * multval, term5 * multval * multval * multval * multval * multval);

return 0;
}

it seems like a lot to read but its actually simple. the program accepts as input 5 values in a series, then determines if it is a series of numbers multiplied by the same number every time or a series of numbers that just adds a certain value every time. I bolded the lines that the errors show up on (posted below). The user defined functions are getTerms, getPattern, patternAdd, and patternMultiply. ive been trying to debug this for hours and just can't figure it out. any help?

hw6.c: In function 'main':
hw6.c:23: error: expected expression before 'int'
hw6.c:23: error: too few arguments to function 'getPattern'
hw6.c:25: error: expected expression before 'int'
hw6.c:25: error: too few arguments to function 'patternMultiply'
hw6.c:29: error: expected expression before 'int'
hw6.c:29: error: too few arguments to function 'patternAdd'
hw6.c: At top level:
hw6.c:54: error: expected ';', ',' or ')' before '*' token
hw6.c:77: error: expected ';', ',' or ')' before '*' token
hw6.c:94: error: expected ';', ',' or ')' before '*' token

you are getting those errors like on line 23 because you put data types as parameters and it expects variable names. For example: if( getPattern(&term1, &term2, &term4, &term5) ) == 1)

This article has been dead for over six months. Start a new discussion instead.