please explain this

cout<<'a';
cout<<'10';
cout<<'15.5';
a,10,15.5 are data constants.now,the question is how these data types are stored in memory.so,for finding that we can use the sizeof() funtion eg: sizeof(10)= 2 bytes.therefore we get know that 10 will be stored as an int data type.
1)here,what does storing really mean?could you please give an example where a data constant like 10 is being stored.
sizeof(10)= 2 bytes.therefore we get know that 10 will be stored as an int data type
Before I get to the main point of your question, I just want to say that this is a fallacy of affirmation of the consequent. Just because int uses 2 bytes doesn't imply that anything that uses 2 bytes is an int. For example, a char[2] also uses 2 bytes, but it's not an int.

1)here,what does storing really mean?could you please give an example where a data constant like 10 is being stored.
Integer literals aren't stored in the same sense as you'd store a variable. That is, there isn't a place in memory where integer literals are stored. Instead, integer literals are encoded as part of the generated machine instructions. For example, when you do
x+=10;
the compiler may ultimately translate this into
add eax, 10
It's important to note that the "10" is part of the instruction. You can think of it like the CPU having a myriad of operations, like add1, add10, add615, and so on, that all change the state of the machine in different ways.
cout<<'a';
this will display the ASCII code of 'a'
this is also called character constants it is internally treated as integer
Topic archived. No new replies allowed.