void main()

{

static int i=i++, j=j++, k=k++;

printf(“i = %d j = %d k = %d”, i, j, k);

}

Answers were Sorted based on User's Feedback



void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, ..

Answer / susie

Answer :

i = 1 j = 1 k = 1

Explanation:

Since static variables are initialized to zero by default.

Is This Answer Correct ?    12 Yes 8 No

void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, ..

Answer / mittu

0 ,0 ,0

It gives 0 0 0 for all three.
Cause at compile time compiler assigns memory to the static variable in HEAP. So these are automatically initialized to 0.

So First Allocation and then Initialization takes place.

At compile time it allocates memory to i,j,k.
And then initialization phase first is assigns 0 to 'i','j' and 'k' and
then it uses this ++ for increment the value at "Increment Buffer".
So i,j,k are initialized by 0 and value of i , j,k is incremented by 1 in "Increment Buffer".

THIS IS DONE AT COMPILE TIME.

Now at run time it refers the value of i,j and k from HEAP.
And at run time it skips "static statements".

So in HEAP value of i , j, and k is 0(zero).

Is This Answer Correct ?    5 Yes 1 No

void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, ..

Answer / ankur

illegal initialization

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Code Interview Questions

#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer

1 Answers  


void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  


void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }

1 Answers  


Write a program to receive an integer and find its octal equivalent?

7 Answers  


programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  






write a origram swaoing valu without 3rd variable

2 Answers  


main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user

2 Answers   HCL,


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


program to find magic aquare using array

4 Answers   HCL,


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4

2 Answers   HCL,


main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }

3 Answers   Hexaware,


Categories