I want to create an array and raise 2 to every element in that array and store it as new array arr2. Here is my code
#include <iostream>
using namespace std;
int main(){
int arr1[7] = {1, 2, 3, 4, 5, 6, 7};
auto arr2 = 2 ** arr1;
cout << arr2 << endl;
}
But, it prints only the first element, it does not print the whole array. Why? So, basicaly, what I did here is I created arr1 with elements {1,2,3,4,5,6,7} and then I want arr2 to be
- [2, 4, 8, 16, 32, 64, 128]
but for some reason it prints only the first element of array, it prints 2, but I want it to print all elements. Notice that 2 ** arr1
is the line where I am raising 2 to power (using exponentiation operator, i think it is how you call it if I'm not wrong) and then it should store array at array2.
What is wrong and why does it print only the first element instead all the elements?