GATE | GATE CS Mock 2018 | Question 39

Consider the following C-program :

filter_none

edit
close

play_arrow

link
brightness_4
code

int fun()
{
  static int num = 16;
  return num--;
}
  
int main()
{
  for(fun(); fun(); fun())
    printf("%d ", fun());
  return 0;
}

chevron_right


What is output of above program?

(A) Infinite loop
(B) 13 10 7 4 1
(C) 15 12 8 5 2
(D) 14 11 8 5 2


Answer: (D)

Explanation: Option (D) is correct. Refer : https://www.geeksforgeeks.org/c-storage-classes-and-type-qualifiers-question-9/

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.