![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Junior Member Join Date: Aug 2006 Age: 26
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | 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 |
| | |
| | #2 (permalink) |
| (e)x-member Join Date: Jul 2006 Location: India
Posts: 774
Thanks: 29
Thanked 34 Times in 30 Posts
Rep Power: 12 | 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? |
| | |
![]() |
| Tags |
| puzzle , simple |
| 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 |
| 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 |
| More Interview Questions Here... |