65

Predict the Output:
int main()
{
int *p=(int *)2000;
scanf("%d",2000);
printf("%d",*p);
return 0;
}

if input is 20 ,what will be print

Output:
20
Logic:
we know that pointer stores address.
we can specify address directly like this
"(datatype *)address"

pointer 'p' is pointing the address 2000.
scanf("%d",2000) will write the data which is entered by user into the address 2000.
so 20 will store in the address 2000.
now *p will points the value at the address,so 20 will print.

Related Posts