![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| (e)x-member Join Date: Jul 2006 Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 | predict the output What's the output of the following program and why? #include { float a = 12.5; printf("%d\n", a); printf("%d\n", *(int *)&a); return 0; }
__________________ "I always like to walk in the rain as no one can see me crying! -Charlie Chaplin" |
| | |
| | #2 (permalink) |
| Junior Member Join Date: Aug 2006 Age: 23
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: predict the output hey a is float value but ur giving %d it will give error |
| | |
| | #3 (permalink) |
| (e)x-member Join Date: Jul 2006 Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 | Re: predict the output plz note that though output may be wrong but this program will compile successfully. compiler won't give any error in this case. nothing much in this question. |
| | |
| | #4 (permalink) |
| Junior Member Join Date: Aug 2006 Age: 23
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: predict the output hi ok thank u for answering |
| | |
| | #5 (permalink) |
| Member Join Date: Aug 2006 Age: 24
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 4 | Re: predict the output #include { int a = 12; printf("%d\n", a); printf("%f\n", *(float *)&a); return 0; } will this work? |
| | |
| | #6 (permalink) |
| (e)x-member Join Date: Jul 2006 Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 | Re: predict the output float *p means pointer to a float. in this case 'a' happens to be an int, so this won't work. if u declare 'a' as float then this will be ok. I think u can explain it better. so go ahead. thx for asking. |
| | |
![]() |
| Tags |
| output , predict |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to get output of 0 for 1 , 1 for 0 | murari | DATA STRUCTURES, C, C++, VC ++ | 10 | 15-10-06 07:06 AM |
| predict the output | WISDOM | DATA STRUCTURES, C, C++, VC ++ | 5 | 01-09-06 02:59 PM |
| DNA could predict your surname | BINNY | Latest Tech News & Innovations | 3 | 15-03-06 12:36 PM |
| Formatting TOAD output | poshpearl17s | ORACLE , SQL SERVER , SYBASE & Others | 13 | 14-03-06 07:08 AM |
| Please Tell me The FUNDA Behind d OUTPUT | jobs4akhilesh | DATA STRUCTURES, C, C++, VC ++ | 8 | 06-03-06 05:35 AM |
| More Interview Questions Here... |