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 |
Print an integer using only putchar. Try doing it without using extra storage.
char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }
Write a single line c expression to delete a,b,c from aabbcc
can u give me the c codings for converting a string into the hexa decimal form......
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }
main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }
source code for delete data in array for c