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;
}
It prints ASCII value of the binary number present in the first byte of a float variable a.
It prints character equivalent of the binary number present in the first byte of a float variable a.
It will print 3
It will print a garbage value
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
50 comments Page 3 of 5.

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.

Pranali said:   8 years ago
@Siri.

ASCII value is in the form of integer. And for printing decimal integer we have used %d format specifier. Got it?

Balashankar said:   1 decade ago
Float value is stored in memory as IEEE754 format. This is different from normal binary conversion.

Mukta said:   4 years ago
@HImanshu Chauhan.

printf prints it in a format you want and scanf accepts whatever you enter.

Himanshu Chauhan said:   1 decade ago
Hey can any one please explain me that what is the main difference between printf and scanf?

Sunil patidar said:   1 decade ago
@kiran Global variables are stored on data segment.
the static variables are stored on heap.

Parmeshwar said:   6 years ago
It's a garbage value -61 ... And the float.
It's a cycle of signed range.... -127 to 127.

Rupinderjit Singh said:   1 decade ago
Static variables are stored on stack and Heap is only used for dynamic memory allocation.

Priya said:   1 decade ago
Hut the output is -61 and it is not ASCII value of a so anyone can explain this ans?

Shankar said:   1 decade ago
GLOBAL variables are store in permanent storage area i.e static memory.


Post your comments here:

Your comments will be displayed after verification.