You are not logged in. Please login at www.codechef.com to post your questions!

×

What is difference between int and long ?

in c or c++ int and long have same size then what is main difference between long and int?

asked 14 Sep '17, 23:25

upenkumar31's gravatar image

2★upenkumar31
423
accept rate: 22%


Some compilers actually have long as 64 bit. The thing is, size of long is compiler dependent. Sometimes its 32 bit, sometimes 64 bit. But in most cases (esp. online compilers) you will encounter long being 32 bit.

Its better to go with long long which is a sure 64 bit to avoid unnecessary errors.

link

answered 14 Sep '17, 23:38

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066
accept rate: 18%

link

answered 14 Sep '17, 23:56

utkalsinha's gravatar image

6★utkalsinha
851118
accept rate: 13%

The storage capacity. An old-style compiler could allocate e.g. 16 bits of storage for an int and 32 for a long. Actual sizes vary between compilers. If you are going to use very large numbers,use long. Hope this clears.

link

answered 15 Sep '17, 04:00

prem7ranjan3's gravatar image

0★prem7ranjan3
111
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,916
×1,490
×966
×47

question asked: 14 Sep '17, 23:25

question was seen: 1,170 times

last updated: 15 Sep '17, 04:00