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

How to palindrom string in c language?

6 Answers   Google,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


Derive expression for converting RGB color parameters to HSV values

1 Answers  


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,






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

1 Answers  


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


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

1 Answers   TCS,


Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513

3 Answers   HCL, Logical Computers,


1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?

2 Answers  


Write a function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


Categories