hello every body!
i have very simple question, i google it alot but i didn't find the satisfactory answer my question is
what is the reason that int, float,char,double,bool are of 4,4,1,8,1 byte respectively in C++?
are arrays built in? if yes then kindly explain......thnx alot

char is of 1 byte because each char has an ascii value of max 127 if we r using 8 bit encoding. 128 = 2 power 8. so 8 bits 1 byte.

> what is the reason that int, float,char,double,bool are of 4,4,1,8,1 byte respectively in C++?
This isn't a C++ question, it's a "what does your compiler do" question.

The C++ standard only specifies MINIMUM requirements on the data types. Beyond that, the compiler implementor is free to do anything they like.
For example, CHAR_BIT (the number of bits in a char) is specified to be at least 8. Does that mean it is ALWAYS 8 - nope. Some obscure DSP chips have 32-bit chars (and before someone asks about sizeof, yes sizeof(char) on this machine is 1).

Likewise int etc have specified minimum ranges.

> are arrays built in? if yes then kindly explain......thnx alot
Any book should tell you the answer to that!

>what is the reason that int, float,char,double,
>bool are of 4,4,1,8,1 byte respectively in C++?

Perhaps if you explain why you think those values are wrong, we can offer enlightenment.

>are arrays built in?
Do you need to include a header? No? They might just be "built in" then.

>128 = 2 power 8. so 8 bits 1 byte.
sizeof(char) is 1 regardless of how many bits are in a byte, and there are platforms where a byte is not 8 bits. Welcome to the world of portability. Your PC assumptions no longer hold water.

This article has been dead for over six months. Start a new discussion instead.