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
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 |
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 |
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }
Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }
how to return a multiple value from a function?
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }
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
#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }
#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }
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']
#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); }
what is brs test reply me email me kashifabbas514@gmail.com
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }