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.




simple c puzzle

        

Reply
 
LinkBack Thread Tools Display Modes
Old 14-08-06, 09:56 PM   #1 (permalink)
Junior Member
 
Join Date: Aug 2006
Age: 26
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 k_haribob is on a distinguished road
simple c puzzle

int i=1000,j=1000;
long int k=i*j;

will ths code execute..??
if executes i cud not understand why its printing 16960 as the result.

as long int can hold a max value of (2 power 32 -1)...long int 4 bytes.

pls answer to ths...byee

k_haribob is offline Offline   Reply With Quote
Old 15-08-06, 12:50 AM   #2 (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: simple c puzzle

Since both i and j are integers, their multiplication will result an int and then that int value is assigned to K. It does not matter whether K is int or long since the multiplation result will be truncated to fit to int size before it is assigned to K. If u want correct answer, then try to declare x or y as long int or use type casting as long int K = (long) x * y ;
I hope this solves u'r doubt?
WISDOM is offline Offline   Reply With Quote
Reply

Tags
puzzle , simple


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
tips for interview ozobalu HR Questions 13 14-11-09 01:50 AM
must read all UG students!!!!!!!!!!!!! sanjay Other Queries 16 07-02-09 02:31 PM
simple vs real frd Spoorthi JOKES , PRANKS & QUOTES 10 15-12-06 09:44 PM
Puzzle Contest-124 HELP Brain Teasers - Puzzles 4 22-07-06 04:14 PM
try to solve the puzzle of earth nareshb513 Aptitude Questions 31 16-03-06 04:41 AM


All times are GMT +6.5. The time now is 08:15 AM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.0