0
Help add up the elements in the array.
#include <iostream> #include <math.h> using namespace std; int main() { const int size = 9; int arr[size]; arr[0] = 2; cout << "Your array: "; for (int i = 0; i < size; i++) cout << pow(arr[0], i) << ' '; }
4 Respuestas
0
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
const int size = 9;
int arr[size];
arr[0] = 2;
int sum=0;
cout << "Your array: ";
for (int i = 0; i < size; i++){
sum+=arr[i];
}
cout<<sum;
}
0
Like this??
0
No.Atul
There are two task.
1. Fill an array of 10 elements powers of two. ( I did this.) Array (1 2 4 8 16 32 64 128 256)
2. Calculate the sum of the numbers from the array obtained in the first task.
0
Sum of 1 2 4 8....?