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 |
#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer
void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }
main() { extern out; printf("%d", out); } int out=100;
Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.
How can you relate the function with the structure? Explain with an appropriate example.
Find the largest number in a binary tree
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }
create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }
Cluster head selection in Wireless Sensor Network using C programming language.
#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??