proc() {
static i=10;
printf("%d",i);
}
If this proc() is called second time, what is the output?
Answers were Sorted based on User's Feedback
Answer / sujith
I dont know how can it be 11 next time.
I agree that static variables are assigned only once, and
allocation is happening to the data segment, but it doesnt
mean that is going to change the value on its own, until u
do that manually.
U call this program for n times, the answer is going to be 10.
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / suchita
the answer is 10 bcoz no increment statement in that loop. if
increment statement is there then definitely the value of
static variable is increased. otherwise it is fixed.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / vignesh1988i
if it is called for second time also ,it will be 10 only but
in a different thought....
static keyword is only one time initilization....if the
compailer when again reads the same line it blindly ignores
it and print the latest value of yhat static variable
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / jeevan
There is not increment statement. In this case, always it
returs 10 only. even if 'i' is not static type, then also
it returns 10 only....... for confusing in interview, they
might have used 'static' key word here.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / saurabh
does static function increment the counter variable by
one?? if not then how can u say that i value will be
incremented by 1.
finally the i value will be 10 only. it will not
increment.
| Is This Answer Correct ? | 1 Yes | 1 No |
What are the types of type specifiers?
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.
what is the difference between #include<> and #include”…”?
what is the format specifier for printing a pointer value?
Is it possible to pass an entire structure to functions?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
How would you use the functions fseek(), freed(), fwrite() and ftell()?
0 Answers Aspire, Infogain, TISL,
what is the value of b if a=5; b=++a + ++a
31 Answers Infosys, TCS, Tech Mahindra,
how do you programme Carrier Sense Multiple Access
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
code for inverse a matrix