Answer to Question #277299 in C++ for kyut

Question #277299

13. If you declare an array as int vals[5];, then you can double the value stored in vals[2] with the statement _____.


1
Expert's answer
2021-12-08T08:15:57-0500
#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]<<" ";
	} 	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog