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 can i find first 5 natural Numbers without using any loop in c language????????

2 Answers   Microsoft,


void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

1 Answers  


given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit

8 Answers  


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,






#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }

0 Answers   Student,


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

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,


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

1 Answers  


create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"

2 Answers  


main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }

1 Answers  


Categories