Thread: ???? beginner

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    12

    ???? beginner

    Hi all,

    I have a test in the morning and cant get my program to compile any suggestions would be great!

    Code:
    #include <stdio.h>
    
    
    
    float absoluteValue (float x)
    
    {
    	
    if (x < 0)
    	    
    x = -x;
    	
    return (x);
    }
    
    
    
    //Function to compute the sqaure root of a number
    
     float  SquareRoot (float x)  
    
     {  
       
      float  guess   = 1.0;  
        
     float  epsilon = .00001;  
    
       
        
     while  ( absoluteValue((guess * guess) / x  - 1.0) >= epsilon )  
        
     guess = ( x / guess + guess ) / 2.0;  
      
       
     return guess;  
    
     } 
    
    
    int main(void)
    
    {
    
    	
    printf("SquareRoot (2.0) = %2.f\n", SqaureRoot (2.0));
    	
    printf("SquareRoot (144.0) = %2.f\n",SquareRoot (144.0));
    	
    printf("SquareRoot (17.5) = %2.f\n", SqaureRoot (17.5));
    
    	
    
    return 0;
    }
    
    //compiler error
    prog8.5.c: In function ‘main’:
    prog8.5.c:29: warning: format ‘%2.f’ expects type ‘double’, but argument 2 has type ‘int’
    prog8.5.c:31: warning: format ‘%2.f’ expects type ‘double’, but argument 2 has type ‘int’
    /tmp/ccL4vQGf.o: In function `main':
    prog8.5.c:(.text+0x98): undefined reference to `SqaureRoot'
    prog8.5.c:(.text+0xd5): undefined reference to `SqaureRoot'
    collect2: ld returned 1 exit status

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    prog8.5.c.text+0x98): undefined reference to `SqaureRoot'
    Are you telling me that this isn't enough information for you to fix this on your own? Look at the 'a' and 'u'...
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    Since you're using gcc, you should be using the -Wall flag. Always build with -Wall, as it will give you extra warnings that are, for the most part, extremely useful.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    12
    thanks that fixed the problem silly things like that ey you dont realise thanks for your time

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ADO.NET in VS2008 or gdi+ (beginner question)
    By robgar in forum C# Programming
    Replies: 3
    Last Post: 10-04-2009, 02:40 AM
  2. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  3. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM