Bitwise Operators :

Pasted image 20231217163102.png

  • here the value stored is 20.

Left Shift and Right Shift : 01. Lecture 1

Masking and Merging :

Masking :

Knowing if a particular bit inside a memory is on or off is called masking.
We use and (&) operator here.
Pasted image 20231217164632.png

Merging :

Turning a bit on or off is called Merging.
We use or (|) operator here.
Pasted image 20231217170029.png

Pointers

Passing a pointer by reference and by value :

#include <iostream> 

using namespace std; 

int global_Var = 42; 

// function to change pointer value 
void changePointerValue(int *pp) 
{ 
    printf("pp: %d\n", pp);
    printf("&pp: %d\n", &pp);
	pp = &global_Var; 
} 

int main() 
{ 
	int var = 23; 
	int* ptr_to_var = &var; 

	cout << "Passing Pointer to function:" << endl; 

	cout << "Before :" << *ptr_to_var << endl; // display 23 

    printf("ptr_to_var: %d\n", ptr_to_var);
    printf("&ptr_to_var: %d\n", &ptr_to_var);
	changePointerValue(ptr_to_var);


	cout << "After :" << *ptr_to_var << endl; // display 23 

	return 0; 
} 
  • Output :
    Pasted image 20231223183330.png