Help!!this program is Recursive Function or not?

This is a discussion on Help!!this program is Recursive Function or not? within the C Programming forums, part of the General Programming Boards category; hi. i am learning C no longer so can any one help me. this program is Recursive Function or not? ...

  1. #1
    Unregistered
    Guest

    Help!!this program is Recursive Function or not?

    hi. i am learning C no longer so can any one help me.
    this program is Recursive Function or not? Thank you...
    #include<stdio.h>
    int recurstr(char str[50],int n);

    void main()
    {
    char str[50];
    int n;
    clrscr();
    printf("Enter sentence : ");
    gets(str);
    printf("Enter times of display : ");
    scanf("%d",&n);
    recurstr(str,n);
    getch();

    }

    int recurstr(char str[50],int n)
    {
    if(n==0)
    return 0;
    else
    {
    printf("\n%s ",str);
    return recurstr(str,n-1);
    }
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Recursion means that a function calls itself. This means that in the actual function body itself, it a call to that function.

    Code:
    void crash( void )
    {
        printf( "Crash." );
        fflush( stdout );
        crash( );
    }
    See? Inside the function 'crash', it calls the function 'crash'. This is recursion.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unregistered
    Guest

    Smile

    so the function call itself is recursive.
    OIC!!
    Thank you ,Quzah

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Unregistered
    so the function call itself is recursive.
    OIC!!
    Thank you ,Quzah
    Yes. That's the definition of recursion: A function that calls itself.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. recursive function
    By technosavvy in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 05:42 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. function
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 06-02-2002, 08:38 PM

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