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
How do I use strcmp?
What is the best way to comment out a section of code that contains comments?
Explain that why C is procedural?
What is the difference between new and malloc functions?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
When should I declare a function?
can we have joblib in a proc ?
What is the difference between int main and void main?
What do you mean by dynamic memory allocation in c? What functions are used?
How can I read/write structures from/to data files?
What does the c in ctime mean?
What does *p++ do?
Why doesn't C support function overloading?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?