English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

int main()
{
int i;
for(i=0;i<10;i++)
Display();

return 0;
}

void Display()
{
static int i =0;
printf("%d",i++);

}

2006-11-04 06:11:25 · 14 answers · asked by Siu02rk 3 in Computers & Internet Programming & Design

14 answers

0123456789

2006-11-04 06:14:48 · answer #1 · answered by renegadeconformist 2 · 0 0

0 1 2 3 4 5 6 7 8 9

2006-11-04 14:17:01 · answer #2 · answered by Vaibhav 4 · 0 0

15

2006-11-04 14:14:07 · answer #3 · answered by hayley a 2 · 0 0

static data type retains their previous values and hence the display will be as follows:
1 // i is incremented to 1 from its initial value i.e 0
2 // i is incremented by 1 from its previous value i.e 1
3 // i is incremented by 1 from its previous value i.e 2
4 // and so on.(Each time previous values are retained)
5
6
7
8
9
Note : if the keyword static wouldnot have been used in the function call with integer variable i , then the result would have been '1' displayed nine times . In absence of the keyword static , previous valuse is not retained and each time the function is called , the value of integer variable " i "will be reset to "0".

2006-11-04 14:43:38 · answer #4 · answered by nfactor26 2 · 2 0

it will say 0

2006-11-04 19:10:47 · answer #5 · answered by kevin m 2 · 0 0

I believe it will print the following:

0000000000

2006-11-05 02:33:26 · answer #6 · answered by FabMom 4 · 0 0

That is a trick question!!! There would be no output!!

2006-11-04 14:15:08 · answer #7 · answered by sabby 1 · 0 0

that is a trick question, there will b no output!

2006-11-04 14:35:33 · answer #8 · answered by Anonymous · 0 0

does this link help at all?
http://www.eskimo.com/~scs/readings/voidmain.960823.html

2006-11-04 14:15:11 · answer #9 · answered by brainlady 6 · 0 0

ok, time for you to go to bed
night

2006-11-04 14:13:53 · answer #10 · answered by pepzi_bandit 2 6 · 0 0

fedest.com, questions and answers