C - Data Types - Discussion

You Are Here :: Home > C > Data Types - Discussion

 



Q.

#include

void visit();
int main(){
int i=0;
{ //Opening inner block
static int a=5; //locally declaration
XYZ:; //Label of goto statement
printf("%d ",a);
a++;
i++;
} //closing inner block.
visit();
/* printf("%d",a); Variable a is not visible here but it is alive. */
if(i<5)
goto XYZ;
return 0;
}
void visit(){
}

A. 5 5 5 5 5 B. 6 6 6 6 6
C. 5 6 7 8 9 D. error

Answer: Option C
Explaination:

If we static variable has declared locally or globally its scope will always whole the program.



Discussion

Your Comments Goes here...
NameDiscussion