in DS edited by
556 views
0 votes
0 votes

When a function is recursively called, all automatic variables :

  1. are initialized during each execution of the function

  2. are retained from the last execution

  3. are maintained in a stack

  4. are ignored

in DS edited by
556 views

1 Answer

1 vote
1 vote
void seq(int num){

     if(num<1)

          return;

     int a = num; // Automatic Variable.

     printf("%d, ", a);     

     seq(num-1);

}

seq(5);

O/P: 5, 4, 3, 2, 1

Here automatic variable "a" is initialized 5 times. Once for each call to seq() with non zero positive number as an argument.