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



proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

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

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

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

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

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

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

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

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

Answer / krupakar

The answer is 10.

Is This Answer Correct ?    1 Yes 0 No

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

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

proc() { static i=10; printf("%d",i); } If this proc() is called second time, ..

Answer / guest

11

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More C Interview Questions

How do I use strcmp?

0 Answers  


Which programming language is best for getting job 2020?

0 Answers  


I have an array of 100 elements. Each element contains some text. i want to: append a star character to the end of every fifth element remove every second character from every tenth element, and… add a line feed (ascii 10) after the 30th character of every array element whose length is greater than 30 characters.

1 Answers  


int a[3][5]={ {1,2,3,4,5],{2,3,4,5,6},{10,11,12,13,14}}; int *p=&a; printf(“%d”,*(*(x+1)+3));

2 Answers   Wipro,


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

0 Answers  






Explain what does a function declared as pascal do differently?

0 Answers  


how to use virual function in real time example

1 Answers   CTS, Wipro,


How can I access an I o board directly?

0 Answers  


What is volatile variable how do you declare it?

0 Answers  


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

0 Answers  


Subtract Two Number Without Using Subtraction Operator

0 Answers  


What are the similarities between c and c++?

0 Answers  


Categories