Interviews9 answers
int is 2 byte and char 4 byte why?
9 Answers
Int store number and character store values
Yogesh SevankarPosted Oct 17, 2019, 10:36 PM EDT
It depends on the processor. It can be two bytes or four bytes.
vineel vatsavPosted Sep 6, 2015, 6:10 PM EDT
I know it's equal to sizeof(int). The size of an int is really compiler dependent. Back in the day, when processors were 16 bit, an int was 2 bytes. Nowadays, it's most often 4 bytes on a 32 bits system or 8 bytes on 64 bits system.
Ajeet MishraPosted Sep 3, 2015, 5:15 AM EDT
i think ur question is wrong mr shamse alam.
integer size is: 4bytes
and
char size is only 2bytes in c# .net.
their is no point in ur question saying int is 2 byte and char is 4 byte.. ur absolutely wrong...
Srinivas PabballaPosted Aug 28, 2015, 1:13 AM EDT
Char: It is 2 bytes in C# because .NET uses UTF-16 for strings (UTF-32 would be 4 bytes). Almost all possible characters in human language can be expressed with 2 bytes (all English letters only require 1 byte) - SO Post: http://stackoverflow.com/questions/6781886/why-do-char-takes-2-bytes-as-it-can-be-stored-in-one-byte
Int: This is 4 bytes (Int32). The only 2 byte numerical value in .Net is a short, which is (Int16). A nice SO reference: http://stackoverflow.com/questions/13351012/how-many-bytes-of-memory-does-each-type-in-net-consume-32-bit-environment
Jason WilczakPosted Jul 7, 2015, 9:25 AM EDT
https://msdn.microsoft.com/en-us/library/x9h8tsay.aspx
Pankaj Kumar ChoudharyPosted Jul 2, 2015, 8:37 AM EDT
BECAUSE INT -NUMERICAL TYPE VALUE AND
CHAR- CHARECTER TYPE VALUE
Bir SinghPosted Jul 1, 2015, 9:50 PM EDT
int takes 16 bit memory,so it take two byte.Actually char take one byte.In your case you may declare char[4] so it takes four byte.Generally character take 1 byte
Sethupalniyappan SubramanianPosted Jun 29, 2015, 12:51 AM EDT
https://msdn.microsoft.com/en-us/library/x9h8tsay.aspx
Sujeet SumanPosted Jun 26, 2015, 1:41 AM EDT





