# Thread: Why Do I keep Getting this Error Message?

1. ## Why Do I keep Getting this Error Message?

Hi, so im trying to write a program in C that solves for the 2 roots of a quadratic equation.

However I keep getting these errors:
cpp(13) : error C2064: term does not evaluate to a function taking 1 arguments
cpp(14) : error C2064: term does not evaluate to a function taking 1 arguments

My code is...

Code:
```#include <stdio.h>
int main()
{
int a,b,c,d,sqrt;
float root1,root2;
printf("Enter A:");
scanf("%d%d%d",&a);
printf("Enter B:");
scanf("%d",&b);
printf("Enter B:");
scanf("%d",&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
root2=((-b)-sqrt(d))/(2*a);
printf("root1=%f & root2=%f",root1,root2);
}```

BTW, Line 13 and 14 are the ones with the "root1=((-b)+sqrt...etc"

So, can someone please help me with what is wrong?
Thanks

2. It isn't going to understand "(-b)" ...

You need to convert b to a negative number by other means.

3. Originally Posted by Nothing595
BTW, Line 13 and 14 are the ones with the "root1=((-b)+sqrt...etc"

So, can someone please help me with what is wrong?
The problem lies earlier:
Code:
`int a,b,c,d,sqrt;`
You declared sqrt to be an int variable, and then you tried to call it as if it were a function. But of course, you actually do want the function. As such, remove the declaration of sqrt from that line and #include <math.h> instead.

Incidentally, you made another mistake on this line:
Code:
`scanf("%d%d%d",&a);`
Originally Posted by CommonTater
It isn't going to understand "(-b)" ...

You need to convert b to a negative number by other means.
That is not true. (-b) is perfectly fine.

4. Originally Posted by laserlight
That is not true. (-b) is perfectly fine.
Well, I'll be... ya' learn something new everyday!

5. I fixed that, but now I get an error message that says " cpp(15) : error C2668: 'sqrt' : ambiguous call to overloaded function"

My current code is
Code:
```#include <stdio.h>
#include "math.h"
int main()
{
int a,b,c,d;
float root1,root2;
printf("Enter A:");
scanf("%d",&a);
printf("Enter B:");
scanf("%d",&b);
printf("Enter B:");
scanf("%d",&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
root2=((-b)-sqrt(d))/(2*a);
printf("root1=%f & root2=%f",root1,root2);
}```

6. Switch to use a C compiler instead of a C++ compiler.

By the way, you should indent your code properly.

7. So Microsoft Visual C/C++ Express Edition 2008 won't work for it?

8. It probably can, if you configure it, or simply change the file extension to ".c".

9. Or simply declare d as a float also.

10. I think that you should declare: d, root1,root2 as variable type double for more accuracy. Also, the function sqrt() returns a variable type of double.

11. Why Do I keep Getting this Error Message?
<< Because you keep trying to compile that program! >>

Sorry, could not resist.

Popular pages Recent additions