main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}
Answers were Sorted based on User's Feedback
Answer / john lee
main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)++ + (*ptr)++);
}
Like above, code should be revised as allocated memory space just has 2(16bit machine) or 4 byte(32bit machine) to save '4'.
If not, the orginal code, printf("%d",(*ptr)++ + *ptr++);
In my guess, ptr++ will be first, and then *ptr would be next.
If so, ptr++ will point to a memory address unintended(an address +2 or +4 added). And then *ptr will have a value like 0 or else.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vinod
Answer = 8
Explanation:
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
The above statement can be interpreted as (*ptr)++ + *ptr++
(*ptr)++ - Post increment the Value pointer by ptr i.3. 4
*ptr++ - Return the value of ptr and increment the position of ptr i.e. 4
So (*ptr)++ + *ptr++ => 4 + 4 => 8
Is This Answer Correct ? | 1 Yes | 2 No |
how to check whether a linked list is circular.
respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"
can u give me the c codings for converting a string into the hexa decimal form......
Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.
1 Answers Samar State University,
What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }
main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above
main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }