what are the static variables
Answer Posted / prakash.m
static variables are those which retains the outcoming
value after 'n' iterations(initialized once)
(see below)
#include <stdio.h>
int g = 10;
main(){
int i =0;
void f1();
f1();
printf(" after first call \n");
f1();
printf("after second call \n");
f1();
printf("after third call \n");
}
void f1()
{
static int k=0; //static variable
int j = 10; //auto variable
printf("value of k %d j %d",k,j);
k=k+10;
}
the output will be:
value of k 0 j 10 after first call
value of k 10 j 10after second call
value of k 20 j 10after third call
hope this will help u....
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What is the purpose of the preprocessor directive error?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What does the function toupper() do?
Are enumerations really portable?
What are the rules for the identifier?
How can I trap or ignore keyboard interrupts like control-c?
What is an array in c?
What are header files why are they important?
What is scanf_s in c?
How do you define a string?
Write a program to know whether the input number is an armstrong number.
What is the use of getchar() function?
What are the ways to a null pointer can use in c programming language?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Why is event driven programming or procedural programming, better within specific scenario?