Programming for NOOBS : Season 1

Moving on to Address of C variable :
It is literally the address of variables stored in a memory location. Assume internal memory as a small city with numerous houses and buildings which represent nothing but Variables. Each building has its own unique house number and address. Same concept in the case of the C identifier address. 
We use a special character to print the address, &.
main()
{
 int x=69;
cout<<"address of variable x is:"<<&x;
return 0;
}
Invalid syntax: &&x. 
& = address of            so, &x  means the address of the variable x
  by that logic &&x = address of the address of variable x = address of ( address x).
but the address of x is a constant character and the address operator can't be used with constants..

NOTE: the code is written in C++. In c use %u in printf to print the address. 
  • The range of an address is 0000 to FFFF in hexadecimal. 
  • You as a programmer cannot decide where to store the variable in the memory, You cannot decide the address just like you can't choose where to be born. 
  • No two variables have the same physical address. It's a no brainer. 
Operators in C
  • AND                       &     output: 1 if both bits are 1
  • OR                           |    output: 1  if only one value is high 
  • NOT                        ~     output:  inverts the bits
  • XOR                        ^     output: 1 only when two bits have different values  
  • LEFT SHIFT           <<    
  • RIGHT SHIFT         >>  

Comments

Popular Posts