Answer to Question #301434 in C++ for Mateo

Question #301434
  1. Input five integers in one line, with each integer separated by a space.
  2. Add the 1st and 2nd integers together and store the sum inside a variable.
  3. Add the 3rd and 4th integers together and store the sum inside a variable.
  4. Multiply the two sums and raise the product result to the power of the 5th integer.
  5. Print out the result.


Input

A line containing five integers separated by a space.

1·2·3·4·5

Output

A line containing an integer.

4084101




1
Expert's answer
2022-02-23T06:24:40-0500


#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int numbers[5];
	for(int i=0;i<5;i++){
		cin>>numbers[i];
	}
	//Add the 1st and 2nd integers together and store the sum inside a variable.
	int sum12=numbers[0]+numbers[1];
	//Add the 3rd and 4th integers together and store the sum inside a variable.
	int sum34=numbers[2]+numbers[3];
	//Multiply the two sums and raise the product result to the power of the 5th integer.
	long int product=sum12*sum34;
	long int result=pow(product,numbers[4]*1.0);
	//Print out the result.
	cout<<result<<"\n\n";
	system("pause");
	return 0;
}

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