C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-12-2009, 09:51 AM   #1
Registered User
 
Join Date: Sep 2009
Posts: 17
error C2668: 'sqrt' : ambiguous call to overloaded function ???

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;
}
matt.s is offline   Reply With Quote
Old 11-12-2009, 09:54 AM   #2
C++ Witch
 
laserlight's Avatar
 
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   Reply With Quote
Old 11-12-2009, 10:00 AM   #3
Registered User
 
Join Date: Sep 2009
Posts: 17
....how would i do that in Microsoft Visual C++?
matt.s is offline   Reply With Quote
Old 11-12-2009, 10:39 AM   #4
Registered User
 
Join Date: Sep 2009
Posts: 17
figured it out. cheers.
matt.s is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 02:31 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22