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 can I read a binary data file properly?
Why do we use null pointer?
Why enum is used in c?
What is a constant and types of constants in c?
How do I copy files?
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
Is exit(status) truly equivalent to returning the same status from main?
Where are c variables stored in memory?
What is the easiest sorting method to use?
What is the modulus operator?
Difference between constant pointer and pointer to a constant.
an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational
Is c# a good language?
Why can’t constant values be used to define an array’s initial size?