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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use main function?

642


what is use of malloc and calloc?

1388


What is #include in c?

602


What is abstract data structure in c?

533


Explain null pointer.

624






Is boolean a datatype in c?

552


What is the use of header files?

610


Why flag is used in c?

657


How can I dynamically allocate arrays?

599


How is actual parameter different from the formal parameter?

596


What is atoi and atof in c?

620


Explain function?

666


What is const and volatile in c?

570


Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol

670


What are compound statements?

631