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 |
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
Write a procedure to implement highlight as a blinking operation
write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"
Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..
main() { char a[4]="HELLO"; printf("%s",a); }
#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
why nlogn is the lower limit of any sort algorithm?
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];
why the range of an unsigned integer is double almost than the signed integer.
main() { int i=5; printf(“%d”,i=++i ==6); }
what is the code of the output of print the 10 fibonacci number series