13. If you declare an array as int vals[5];, then you can double the value stored in vals[2] with the statement _____.
#include<iostream>
using namespace std;
int main()
{
//According to the conditions we have an array of 5 int
//Fill him by some values
int vals[5] ={10,20,30,40,50};
//We need to double vals[2]
vals[2]*=2;
//Check an array
cout<<"Resulting array: ";
for(int i=0;i<sizeof(vals)/sizeof(int);i++)
{
cout<<vals[i]<<" ";
}
}
Comments
Leave a comment