what are the static variables
Answers were Sorted based on User's Feedback
Answer / nil
Static vairiable is one which can be accessed without
creation of an object of Class i.e. by direct calling calss.
Is This Answer Correct ? | 9 Yes | 0 No |
Answer / 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 |
Answer / smriti patnaik
static variables are variables that are initiated only once
in a memory,suppose u have initiated a variable as static
everytime u visit a iteration the value is changed 4m the
initialised value,not like auto variables where the values
remain same everytime u visit a iteration
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / nitin gupta
a static variable is shared by all the the instances of a
class.
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / subha raman
I have a doubt..what is the difference between.."static"
and "constant(const)"??
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / guest
Variables that statically retain their memeory location
across function calls or in other words even beyond their
scope.
Global static values or functions are used to hide them
from other files in the program.
Is This Answer Correct ? | 0 Yes | 2 No |
What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;
what is pointer ?
10 Answers Kernex Micro Systems,
What are lookup tables in c?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
How to add two numbers with using function?
what is a c-language.what is do.
Difference between constant pointer and pointer to a constant.
what is c language?
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort
Can the sizeof operator be used to tell the size of an array passed to a function?
#include<string.h> void main() { String s1[]={"swathi"}; string s2[]={"maddimsetti"}; s1[]=s[]; printf("%s",s1[]); }
Explain the difference between ++u and u++?