+ which follows 0 is due to null character at the end of the string
and it will not be printed on the console." - " which follows " + " is
due to same reason. The null character is returning condition from the
recursion, after that each character of string preceded by "-" is
printed on the screen

On Sun, Jul 24, 2011 at 9:43 PM, nullpointer <[email protected]> wrote:
> #include <stdio.h>
> #include <string.h>
> void printit(char line_of_char[], int index);
> int main()
> {
> char line_of_char[80];
> int index = -1;
>  strcpy(line_of_char, "1234567890");
>  printit(line_of_char, index);
>  return 0;
> }
> void printit(char line_of_char[], int index)
> {
>  if(line_of_char[index])
>  {
>  index++;
>  printf("+%c", line_of_char[index]); /*how come this is not being
> printed after "-" was printed*/
>  printit(line_of_char, index);
>  printf("-%c", line_of_char[index]);
>  }
> }
> o/p=+1+2+3+4+5+6+7+8+9+0+--0-9-8-7-6-5-4-3-2-1
> can anyone explain how this program is working( why +-- between two
> zero's  and how second printf is returning value in recursion)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Sanjay Ahuja,
Analyst, Financing Prime Brokerage
Nomura Securities India Pvt. Ltd

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to