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
Differentiate between calloc and malloc.
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.
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
what are the different storage classes in c?
How can I do peek and poke in c?
Is using exit() the same as using return?
What is difference between structure and union in c programming?
What is modifier & how many types of modifiers available in c?
what is the role you expect in software industry?
Why are all header files not declared in every c program?
is it possible to create your own header files?
Write a C program to count the number of email on text
How can I call a function with an argument list built up at run time?
How can I make sure that my program is the only one accessing a file?
What does printf does?