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
What is the use of bitwise operator?
What is adt in c programming?
What are the string functions? List some string functions available in c.
What is the purpose of & in scanf?
Why is C language being considered a middle level language?
What is the benefit of using #define to declare a constant?
Wt are the Buses in C Language
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
Is fortran still used today?
How can I get random integers in a certain range?
What is c token?
Who developed c language and when?
When should structures be passed by values or by references?
Is c a great language, or what?
What is the difference between c and python?