IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Pointers - Discussion

@ : Home > C Programming > Pointers > Point Out Correct Statements - Discussion

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;
}

[A]. It prints ASCII value of the binary number present in the first byte of a float variable a.
[B]. It prints character equivalent of the binary number present in the first byte of a float variable a.
[C]. It will print 3
[D]. It will print a garbage value

Answer: Option A

Explanation:

No answer description available for this question.


Madhureddy said: (Tue, Feb 1, 2011 04:04:05 AM)    
 
Since here type conversion from float to charecter take place. Hence the ASCII value of the binary number present in the first byte of float variable a will print.

Vinod said: (Sun, Apr 3, 2011 07:41:33 AM)    
 
Can you explain how to came -61.

Durai Pandian said: (Mon, May 23, 2011 11:35:30 AM)    
 
Please whats the meaning of the -61 as output.

Mukesh said: (Fri, Jun 3, 2011 04:56:12 AM)    
 
Where the global variable stored in c language?

Shankar said: (Thu, Jul 7, 2011 08:23:30 AM)    
 
GLOBAL variables are store in permanent storage area i.e static memory.

Kiran said: (Wed, Aug 31, 2011 01:05:52 AM)    
 
Global variables are stored on heap.

Suresh said: (Wed, Aug 31, 2011 12:08:23 PM)    
 
Can you explain how the output get -61?

Saurabh Kumar Verma said: (Sun, Sep 4, 2011 01:46:57 AM)    
 
Can you explain how the output get -61?

Sunil Patidar said: (Sun, Sep 4, 2011 01:49:16 AM)    
 
@kiran Global variables are stored on data segment.
the static variables are stored on heap.

Gyni said: (Tue, Sep 20, 2011 09:07:08 PM)    
 
What is heap? can you segment and static memory storage.

Lalit Singh said: (Tue, Sep 27, 2011 11:48:36 AM)    
 
The answer to this question is wrong it's option D.

Harry said: (Wed, Oct 5, 2011 04:19:41 PM)    
 
Can anyone please explain ? How did this answer come ?

Priya said: (Wed, Oct 5, 2011 10:43:29 PM)    
 
Hut the output is -61 and it is not ASCII value of a so anyone can explain this ans?

Gourav said: (Fri, Oct 7, 2011 07:34:05 AM)    
 
C stores local variables on stack.

Global variables may be declared. These are not stack based. But stored in the data segment.

Rupinderjit Singh said: (Fri, Oct 28, 2011 09:07:29 PM)    
 
Static variables are stored on stack and Heap is only used for dynamic memory allocation.

Vipul said: (Sat, Dec 17, 2011 06:25:31 PM)    
 
What is heap?

Vipul said: (Sat, Dec 17, 2011 06:28:48 PM)    
 
Please give proper explanation.

Balaji said: (Thu, Jan 5, 2012 11:18:09 PM)    
 
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.

Vishwas said: (Fri, Jan 6, 2012 10:31:24 AM)    
 
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.

Deepa said: (Wed, Jan 11, 2012 07:56:32 PM)    
 
Can anyone explain it clearly?

Sk Rashid Ali said: (Sat, Feb 18, 2012 05:58:43 PM)    
 
If we replace %d with %u its giving an addrress.

Dilip Sharma said: (Mon, Feb 20, 2012 07:39:14 PM)    
 
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
//here j is pointer to char a are declare as 3.14 which is float in third line &a is nothing but the reference of a i.e direct retrived the value 3.14 and cast it as (char*) ;
so here float value are casted.hence it will print the ASCII charactor of first byte.

Vishwas S said: (Wed, Aug 22, 2012 04:54:56 PM)    
 
Can anyone please explain how 3.14 is stored in a computer?

Ganesh said: (Sat, Sep 8, 2012 10:24:26 PM)    
 
@Vishwas
which is the 1st byte in 3.140000? 03 or 00?? whatever it is.. ascii value for 0 is 60 and that of 3 is 63.. so how can ans be -61??

Write your comments here:
Name *:     Email:


© 2008-2013 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!