ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
proc() {

	static i=10;
	printf("%d",i);
	}

	If this proc() is called second time, what is the output? 
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
Answer
# 1
11
 
Is This Answer Correct ?    0 Yes 1 No
Guest
 
  Re: proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
Answer
# 2
I dont know how can it be 11 next time.
I agree that static variables are assigned only once, and
allocation is happening to the data segment, but it doesnt
mean that is going to change the value on its own, until u
do that manually. 

U call this program for n times, the answer is going to be 10.
 
Is This Answer Correct ?    1 Yes 0 No
Sujith
 
 
 
  Re: proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
Answer
# 3
the answer is 10 bcoz no increment statement in that loop. if 
increment statement is there then definitely the value of 
static variable is increased. otherwise it is fixed.
 
Is This Answer Correct ?    1 Yes 0 No
Suchita
 
  Re: proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
Answer
# 4
does static function increment the counter variable by 
one?? if not then how can u say that i value will be 
incremented by 1.
finally the i value will be 10 only. it will not 
increment.
 
Is This Answer Correct ?    1 Yes 0 No
Saurabh
 
  Re: proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
Answer
# 5
if it is called for second time also ,it will be 10 only but
in  a different thought....

static keyword is only one time initilization....if the
compailer when again reads the same line it blindly ignores
it and print the latest value of yhat static variable
 
Is This Answer Correct ?    1 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
i want to know aptitude questions,technical questions  1
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??  2
write a program to search for an element in a given array. If the array was found then display its position otherwise display appropriate message in c language  1
what does " calloc" do? Cadence6
Which command is more efficient? *(ptr+1) or ptr[1]  3
Which of the following is not an infinite loop ? a.while(1){ .... } b.for(;;){ ... } c.x=0; do{ /*x unaltered within theloop*/ ... }while(x==0); d.# define TRUE 0 ... while(TRUE){ .... } TCS4
hat is a pointer? Assurgent3
what is the code for getting the output as * ** *** Caritor4
What is a class?  1
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?  3
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5; TCS4
In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT IBM1
what is the benefit of c30  1
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco5
how to connect oracle in C/C++.  2
C passes By value or By reference? Geometric-Software3
main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? } NDS12
What is the purpose of Scanf Print, getchar, putchar, function?  1
What is external and internal variables What is dynamic memory allocation what is storage classes in C  2
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); } Motorola1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com