Given the following code:
int x = 0; int y = 10; int *ptr = &x; *ptr = -55; x += -52; ptr = &y; *ptr += 52; printf("%d\n", x);
What is printed to the screen?
Explanation :
It will print -107, as *ptr contains the address of x.
first time x = 0
then ptr which contains the address of x is found value -55
after that x also become -55
now x += -52, taking the value of x to -107
C Program:
#include <stdio.h>
int main()
{
int x = 0;
int y = 10;
int *ptr = &x;
*ptr = -55;
x += -52;
ptr = &y;
*ptr += 52;
printf("%d\n", x);
return 0;
}
Output:
Thumbs Up Please !!!
Get Answers For Free
Most questions answered within 1 hours.