Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

What ios diff. Between %e & %f?

3 Answers   Honeywell,


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

0 Answers   GrapeCity,


what are the advantages of a macro over a function?

0 Answers   TCS,


What are multidimensional arrays?

0 Answers  


wat is the output #define VOLEDEMORT _who_must_not_be_named int main() { printf("VOLEDEMORT"); }

2 Answers  


difference between the array and linked list general difference related to memory

2 Answers  


#include<string.h> void main() { String s1[]={"swathi"}; string s2[]={"maddimsetti"}; s1[]=s[]; printf("%s",s1[]); }

3 Answers   IBM,


write a program for 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4

1 Answers  


void main() { int i=5; printf("%d",i++ + ++i); }

21 Answers   ME,


How do I get an accurate error status return from system on ms-dos?

0 Answers  


program to convert a integer to string in c language'

0 Answers  


Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not

9 Answers   Alcatel,


Categories