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
In a header file whether functions are declared or defined?
What is difference between union All statement and Union?
What are all different types of pointers in c?
Is javascript written in c?
What is the c language function prototype?
What are the features of c language?
Explain the properties of union.
what is bit rate & baud rate? plz give wave forms
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Suggesting that there can be 62 seconds in a minute?
What are the storage classes in C?
What is the advantage of a random access file?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
What is substring in c?