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
Why do we use main function?
what is use of malloc and calloc?
What is #include in c?
What is abstract data structure in c?
Explain null pointer.
Is boolean a datatype in c?
What is the use of header files?
Why flag is used in c?
How can I dynamically allocate arrays?
How is actual parameter different from the formal parameter?
What is atoi and atof in c?
Explain function?
What is const and volatile in c?
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
What are compound statements?