Like Tree1Likes
  • 1 Post By Tclausex

beginner trying to print out a recursive function in main

This is a discussion on beginner trying to print out a recursive function in main within the C Programming forums, part of the General Programming Boards category; Hello, I am just practicing some recursion and I am having trouble with printing out a recursive function in main. ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    51

    beginner trying to print out a recursive function in main

    Hello, I am just practicing some recursion and I am having trouble with printing out a recursive function in main. Here is what I have:

    Code:
    // This function adds the squares 4, 5 = 4*4 + 5*5 recursiveley
    int recursive_sumSquares(int m, int n)
    {
        if (m < n)
        {
            return m*m + recursive_SumSquares(m+1, n);
        }
    
        else
        {
            return m*m;
        }
    
    }
    
    int main()
    {
        printf("%d", recursive_sumSquares(4, 7));
    
        return 0;
    }
    I am getting an error that says undefined reference to 'recursive_SumSquares'

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Saratoga, California, USA
    Posts
    334
    C is case sensitive. Within the function recursive_sumSquares you call an unknown function recursive_SumSquares.
    C0__0D likes this.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    51
    Isn't it funny how its always the most simplest thing? Ahhhh!! Thank you friend!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 06-13-2012, 01:34 PM
  2. a program recursive print from 1 to 2^n
    By abbaskhan in forum C Programming
    Replies: 18
    Last Post: 01-11-2012, 08:06 AM
  3. Converting recursive function to tail recursive
    By ajacobs365 in forum C Programming
    Replies: 1
    Last Post: 10-30-2011, 09:15 AM
  4. Recursive print every time...
    By BobDole11 in forum C Programming
    Replies: 5
    Last Post: 10-27-2008, 01:42 AM
  5. recursive main
    By paperbox005 in forum C Programming
    Replies: 7
    Last Post: 08-28-2004, 04:31 PM

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