Integer Pairing
by CodeChum Admin
Now this one's a tad bit tricky, but you can definitely do it!
Instructions:
Input five integers in one line, with each integer separated by a space.
Add the 1st and 2nd integers together and store the sum inside a variable.
Add the 3rd and 4th integers together and store the sum inside a variable.
Multiply the two sums and raise the product result to the power of the 5th integer.
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
#include <iostream>
#include <cmath>
using namespace std;
int main() {
//Input five integers in one line, with each integer separated by a space.
int number1;
int number2;
int number3;
int number4;
int number5;
cin>>number1>>number2>>number3>>number4>>number5;
//Add the 1st and 2nd integers together and store the sum inside a variable.
int sum12=number1+number2;
//Add the 3rd and 4th integers together and store the sum inside a variable.
int sum34=number3+number4;
//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,number5*1.0);
//Print out the result.
cout<<result<<"\n\n";
system("pause");
return 0;
}
Comments
Leave a comment