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

Differentiate between calloc and malloc.

1261


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

1403


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

4356


what are the different storage classes in c?

1177


How can I do peek and poke in c?

1076


Is using exit() the same as using return?

1347


What is difference between structure and union in c programming?

1100


What is modifier & how many types of modifiers available in c?

1027


what is the role you expect in software industry?

2143


Why are all header files not declared in every c program?

1103


is it possible to create your own header files?

1105


Write a C program to count the number of email on text

1913


How can I call a function with an argument list built up at run time?

1242


How can I make sure that my program is the only one accessing a file?

1263


What does printf does?

1243