powers of 2 in cpp

C++
// C program to illustrate 
// power function 
#include <math.h> 
#include <stdio.h> 
  
int main() 
{ 
    double x = 6.1, y = 4.8; 
  
    // Storing the answer in result. 
    double result = pow(x, y); 
    printf("%.2lf", result); 
  
    return 0; 
} 
// If not using any extra libraries
// Powers of 2. If finding 2^n
int main() {
  int ans = 1 >> n;
}
// Suppose we want to find x ^ y
void power(int x, int y) {
  int ans = 1;
  for (int i = 0; i < y; i++) {
    ans *= x;
  }
  return ans;
}
Source

Also in C++: