create an array and fill it in with even numbers. use c++
#include <iostream> using namespace std; int main() { int size; cout << "Enter size of array: "; cin >> size; int *arr = new int[size]; for (int i = 0; i < size; ++i) { arr[i] = 2*(i+1); } cout << "Generated even array is: "; for (int i = 0; i < size; ++i) { cout << arr[i] << " "; } cout << endl; delete[] arr; return 0; }
Get Answers For Free
Most questions answered within 1 hours.