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
How does pointer work in c?
What are the application of c?
What is nested structure in c?
What is the benefit of using an enum rather than a #define constant?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
Wt are the Buses in C Language
What is structure and union in c?
What is pivot in c?
Do you know the use of fflush() function?
What will be your course of action for a push operation?
write a program in c language to print your bio-data on the screen by using functions.
Explain how can I write functions that take a variable number of arguments?
What are structure members?
code for find determinent of amatrix
What are different types of variables in c?