error C2668: 'sqrt' : ambiguous call to overloaded function ???

This is a discussion on error C2668: 'sqrt' : ambiguous call to overloaded function ??? within the C Programming forums, part of the General Programming Boards category; I'm using Microsoft Visual C++ and have this lab due in a couple hours...... However, everytime I try to run ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    54

    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;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,647
    Compile your code as C, not C++.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    54
    ....how would i do that in Microsoft Visual C++?

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    54
    figured it out. cheers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. how to get function call stack
    By George2 in forum C Programming
    Replies: 18
    Last Post: 11-11-2006, 06:51 AM
  4. C2668 - Ambiguous Call to Overloaded Function
    By Osiris990 in forum C++ Programming
    Replies: 6
    Last Post: 10-26-2005, 06:34 AM
  5. ambiguous call to overloaded function
    By LurPak in forum C++ Programming
    Replies: 2
    Last Post: 09-05-2003, 03:37 AM

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