0 0 votes #include<stdio.h> int a = 10; int main() { fun(); fun(); return 0; } int fun() { static int a = 1; printf("%d ",a); a++; return 0; } Programming in C programming-in-c pointers output interview + – Desert_Warrior 932 views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Desert_Warrior commented May 16, 2016 reply Follow flag o\p is 1 2 Correct me If I'm wrong. 1 1 replyShare rajan commented May 16, 2016 reply Follow flag ya right 0 0 replyShare Please log in or register to add a comment.
Best answer 4 4 votes @Lord_Krishna Indeed output is 1 2. Because in 1) presence of local variable with the same name, function will never access the global variable. 2) Static variable declaration will takes place only once. So it can retain its value in different function calls. rude answered May 17, 2016 • selected May 17, 2016 by Desert_Warrior rude comment Share Follow 0 reply Please log in or register to add a comment.