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
Which is an example of a structural homology?
What are the parts of c program?
which is conditional construct a) if statement b) switch statement c) while/for d) goto
What are the string functions? List some string functions available in c.
can we have joblib in a proc ?
Is register a keyword in c?
Write a program of advanced Fibonacci series.
What is a program?
explain what is a newline escape sequence?
Explain Function Pointer?
What is meant by high-order and low-order bytes?
Explain the difference between #include "..." And #include <...> In c?
How the c program is executed?
What is string in c language?
Why is c not oop?