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

#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  


Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


how to return a multiple value from a function?

2 Answers   Wipro,


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  






How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

11 Answers   Deshaw, Infosys,


#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }

1 Answers  


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

3 Answers  


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }

1 Answers  


Categories