SELF
Exam
Programming
Program
What will be output of following program?
#include
int main()
{
int a = 320;
char *ptr;
ptr = (char *)&a;
printf("%d",*ptr);
return 0;
}
Read Solution (Total 3)
-
- In this we will see if the compiler stores the address or the value by little endian or by big endian.
In little endian as it is a char pointer the answer will be 64.
In big endian the answer will be 1. - 8 years agoHelpfull: Yes(1) No(0)
- Ans: 320
*(ptr) is the value stored inside the memory location to which ptr points to. - 10 years agoHelpfull: Yes(0) No(1)
- Given variable is in Int and pointer is in Char..
so we are type casting the value to char - 7 years agoHelpfull: Yes(0) No(0)
SELF Other Question