![]() |
| | #1 |
| Registered User Join Date: Sep 2009
Posts: 17
| error C2668: 'sqrt' : ambiguous call to overloaded function ??? However, everytime I try to run it I keep getting "error C2668: 'sqrt' : ambiguous call to overloaded function", and for the life of me I cannot understand why...... Any help would be greatly appreciated! Thanks! Code: #include <stdio.h>
#include <math.h>
int main(void)
{
int i, n;
float s;
printf("Enter an Integer: ");
scanf("%d", &n); /* obtain number */
if (n>0)
{
for(i=1;i<=n; i++) /* cycle through 1 to n */
{
s = sqrt(i); /* obtain the square root */
if (fmod(s,2) == 0) /* use floating point modular because sqrt returns a float */
/* if the remainder of a division by 2 is 0, then the number is even */
printf("%d\n", (int)i); /* print i value resulting in even square roots */
}
}
else
{
printf("Sorry, try inputting a positive number next time.\n");
}
return 0;
}
|
| matt.s is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 11,275
| Compile your code as C, not C++.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #3 |
| Registered User Join Date: Sep 2009
Posts: 17
| ....how would i do that in Microsoft Visual C++? |
| matt.s is offline | |
| | #4 |
| Registered User Join Date: Sep 2009
Posts: 17
| figured it out. cheers. |
| matt.s is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| dllimport function not allowed | steve1_rm | C++ Programming | 5 | 03-11-2008 03:33 AM |
| We Got _DEBUG Errors | Tonto | Windows Programming | 5 | 12-22-2006 05:45 PM |
| how to get function call stack | George2 | C Programming | 18 | 11-11-2006 07:51 AM |
| C2668 - Ambiguous Call to Overloaded Function | Osiris990 | C++ Programming | 6 | 10-26-2005 06:34 AM |
| ambiguous call to overloaded function | LurPak | C++ Programming | 2 | 09-05-2003 03:37 AM |