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...


consider the following C code
main()
{
int i=3,x;
while(i>0)
{
x=func(i);
i--;
}
int func(int n)
{
static sum=0;
sum=sum+n;
return(sum);
}
the final value of x is

Answers were Sorted based on User's Feedback



consider the following C code main() { int i=3,x; while(i>0) { x=fu..

Answer / naksh @tcs

Answer is 6;

Sum being the static variale will retain its value state
between he function calls.

Is This Answer Correct ?    17 Yes 2 No

consider the following C code main() { int i=3,x; while(i>0) { x=fu..

Answer / yogendra jain

6

Is This Answer Correct ?    15 Yes 2 No

consider the following C code main() { int i=3,x; while(i>0) { x=fu..

Answer / vignesh1988i

the final value of x is 6

Is This Answer Correct ?    10 Yes 1 No

consider the following C code main() { int i=3,x; while(i>0) { x=fu..

Answer / manishsoni

we know that the static can't change its value but in
functions:-
"This inside a function static variable retains its value
during various calls."
{
static sum=0; at i=3;sum=0+3;save or retains sum=3
sum=sum+n; at i=2;sum=3+2:save or retains sum=5
return(sum); at i=1;sum=5+1;save or retains sum=6
}
so the final value is 6;

if here we declare sum as auto type then it didn't retains
its value or print 1;sum=0+1;

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Interview Questions

how can i sort numbers from ascending order and descending order using turbo c..

1 Answers  


Difference between null pointer and dangling pointer?

7 Answers   GE, Wipro,


write a own function for strstr

1 Answers   LG Soft,


an algorithem for the implementation of circular doubly linked list

1 Answers  


what is the importance of spanning tree?

0 Answers  


Explain setjmp()?

0 Answers  


find largest element in array w/o using sorting techniques.

3 Answers   Zycus Infotech,


how can u print a message without using any library function in c

1 Answers   NIIT,


what is a headerfile?and what will be a program without it explain nan example?

6 Answers   Assurgent,


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

0 Answers  


Explain the use of function toupper() with and example code?

0 Answers  


Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?

1 Answers   Infosys,


Categories