C Programming - Pointers - Discussion
Discussion Forum : Pointers - Point Out Correct Statements (Q.No. 3)
3.
Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
}
Discussion:
50 comments Page 4 of 5.
Sk rashid ali said:
1 decade ago
If we replace %d with %u its giving an addrress.
Deepa said:
1 decade ago
Can anyone explain it clearly?
Vishwas said:
1 decade ago
Here j is a character pointer, it will hold the address of size 1 byte, but float variable value(3.140000) spread in 4 bytes.
So 1st byte of the float value get printed by the character pointer j.
So 1st byte of the float value get printed by the character pointer j.
Balaji said:
1 decade ago
Char takes in pointer so the first byte takes the role but print the int value so the result is the binary value of the first byte.
Vipul said:
1 decade ago
Please give proper explanation.
Vipul said:
1 decade ago
What is heap?
Rupinderjit Singh said:
1 decade ago
Static variables are stored on stack and Heap is only used for dynamic memory allocation.
Gourav said:
1 decade ago
C stores local variables on stack.
Global variables may be declared. These are not stack based. But stored in the data segment.
Global variables may be declared. These are not stack based. But stored in the data segment.
Priya said:
1 decade ago
Hut the output is -61 and it is not ASCII value of a so anyone can explain this ans?
Harry said:
1 decade ago
Can anyone please explain ? How did this answer come ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers