Create an array of size 15. Multiply even values of array with 3 and place them in the array
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int arr[15];
cout << "Please, enter elements of array: ";
for (int i = 0; i < 15; i++)
{
cin>> arr[i];
}
for (int i = 0; i < 15; i++)
{
if(i%2==0)
arr[i]=arr[i]*3;
}
cout << "Changed array: ";
for (int i = 0; i < 15; i++)
{
cout<<arr[i]<<" ";
}
}
Comments
Leave a comment