I'm using Microsoft Visual C++ and have this lab due in a couple hours......
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;
}