# Thread: Cannot Figure Out Why I Get Parse Error Before ','

1. ## Cannot Figure Out Why I Get Parse Error Before ','

Hello cprogramming.com, I am currently taking my first c programming course as a requirement for my mechanical engineering degree, so please bare with me if i am so oblivious. I am having the hardest time figuring out why i keep getting this parse error.

prompt:

Write a function that accepts two arguments, integer n and real number x, computes the following series, and returns the computed result:

1 – 2(x^2)/1! + 3(x^4)/2! – 4(x^6)/3! + … + [(-1)^n](n+1)(x^2n)/n!

The general term is:

negative one to the power of n
multiply by (n plus one)
multiply by x to the power of (2n)
divided by n factorial

Then write a C program that request two input from the user:
-- an integer number, n
-- a real number, x;

call the function passing those two input as arguments,
output the result returned by the function.

OK, so this is as far as i got. Everything LOOKS right.. but am i missing something so obvious??

Code:
```#include<stdlib.h>
#include<stdio.h>

int main()
{
int x, n;

printf("Enter a value for n.\n");
scanf("%d", &n);
printf("n = %d\n", n);
printf("Enter a value for x.\n");
scanf("%d", &x);
printf("x = %d\n", x);

printf("Result = %d\n", compute(int x , int n));

system("pause");
return 0;
}

int compute(int x, int n)
{
int i, term, xsq, res;
i = 1;
xsq = x*x;
term = -1;

while(i<=n)
{
term = term*(-1)*xsq/i;
i = i+1;
}

res=term*(n+1);

return res;
}```
now when i compile it tells me i have a parse error before ',' in the line that i bolded. can anyone please tell me where i went wrong? Thanks in advance

2. Did you type
Code:
`printf(char * "Enter a value for n.\n");`
or
Code:
`scanf(char *"%d", int * &n);`
? Then why would you type
Code:
`compute(int x , int n)`
?

3. when you call function you do it like this:
Code:
`compute (2,3);`
or like this
Code:
```int x =2;
int n=3;
compute(x,n);```

4. i originally had it down as compute (x,n); but i got a different error that states implicit declaration of function 'int compute(...)', which made it seem like it was worse off..

vart, in my main function, i set the x and n values to be an input from the user so there cannot be any preset values, would there be a different syntax for that? i still do not know why its resulting in the error

5. You need to have a prototype of a function before you can use it (that says "hey this is a function, and it takes these kinds of things, and it returns this sort of a guy".) In this case the prototype is
Code:
`int compute(int x, int n);`
and must appear before it is used.

6. friggin a, duh i cant believe i missed that.. thanks a ton fellas