ExamCompetition Forum Question Papers Ask A Question Mock Test Learn & Earn Sign Up Login Menu



0 vote

Determine Output:void main(){ static int i=5; if(--i){ main(); printf("%d ", i); }}

Asked on by | Votes 0 | Views: 320 | Tags: computer science     | c programming     | c miscellaneous     | Add Bounty

Determine Output:void main(){ static int i=5; if(--i){ main(); printf("%d ", i); }}

A).  5 4 3 2 1

B).  0 0 0 0

C).  Infinite Loop

D).  None of These


Share on Facebook      Share on Whatsapp       Share on Twitter




1 answers

0 vote
Answered by on | Votes 0 |

 0 0 0 0



The variable "i" is declared as static, hence memory for I will be allocated for only once, as it encounters the statement. The function main() will be called recursively unless I becomes equal to 0, and since main() is recursively called, so the value of static I ie., 0 will be printed every time the control is returned.

Join Telegram Group




Answer This Question

Name:
Email:
Answer :
Sum of (4+1)
Submit: