Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the purpose of the preprocessor directive error?

1199


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

1079


What does the function toupper() do?

1065


Are enumerations really portable?

978


What are the rules for the identifier?

1114


How can I trap or ignore keyboard interrupts like control-c?

1020


What is an array in c?

1001


What are header files why are they important?

1044


What is scanf_s in c?

1067


How do you define a string?

1048


Write a program to know whether the input number is an armstrong number.

1073


What is the use of getchar() function?

1074


What are the ways to a null pointer can use in c programming language?

1076


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

1095


Why is event driven programming or procedural programming, better within specific scenario?

2365