45,000 Jobs - Get an Interview Call,  Post Your Resume Here
SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




predict the output

        

Reply
 
LinkBack Thread Tools Display Modes
Old 25-07-06, 04:48 PM   #1 (permalink)
(e)x-member
 
WISDOM's Avatar
 
Join Date: Jul 2006
Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 WISDOM has a spectacular aura about WISDOM has a spectacular aura about
predict the output

What's the output of the following program and why?

#include int main()
{
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"
WISDOM is offline Offline   Reply With Quote
Old 07-08-06, 09:17 PM   #2 (permalink)
Junior Member
 
Join Date: Aug 2006
Age: 23
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 poojareddy is on a distinguished road
Re: predict the output

hey a is float value but ur giving %d
it will give error
poojareddy is offline Offline   Reply With Quote
Old 08-08-06, 12:30 AM   #3 (permalink)
(e)x-member
 
WISDOM's Avatar
 
Join Date: Jul 2006
Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 WISDOM has a spectacular aura about WISDOM has a spectacular aura about
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.
WISDOM is offline Offline   Reply With Quote
Old 08-08-06, 10:59 PM   #4 (permalink)
Junior Member
 
Join Date: Aug 2006
Age: 23
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 poojareddy is on a distinguished road
Re: predict the output

hi
ok thank u for answering
poojareddy is offline Offline   Reply With Quote
Old 17-08-06, 09:20 PM   #5 (permalink)
Member
 
Join Date: Aug 2006
Age: 24
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 4 balanagireddy is on a distinguished road
Re: predict the output

#include int main()
{
int a = 12;
printf("%d\n", a);
printf("%f\n", *(float *)&a);
return 0;
}

will this work?

balanagireddy is offline Offline   Reply With Quote
Old 18-08-06, 01:44 AM   #6 (permalink)
(e)x-member
 
WISDOM's Avatar
 
Join Date: Jul 2006
Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 WISDOM has a spectacular aura about WISDOM has a spectacular aura about
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.
WISDOM is offline Offline   Reply With Quote
Reply

Tags
output , predict


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +6.5. The time now is 04:05 AM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.0