Question

Write code that declares an array of integer values that will represent the first five even...

Write code that declares an array of integer values that will represent the first five even numbers: 2, 4, 6, 8, 10.

Add code to initialize each element of the array with the even number values shown above.

Add code to calculate the product of the array elements, and store the result in a variable named product. You must access the array elements to accomplish this. Do not write

product = 2 * 4 * 6 * 8 * 10;

or

product = 3840;

Print the product that you calculate to the screen, along with a message describing what is being printed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:-

#include <iostream>
using namespace std;

int main() {
   int arr[5]; // declares an array of integer
   int arr1[5]={2,4,6,8,10}; // initialize each element of the array
   int product=1;
   for(int i=0;i<5;i++)
   {
       product=product*arr1[i];
   }
   cout<<"the product of first 5 even number is : "<<product;
   return 0;
}

// OUTPUT

// If any doubt please comment

Add a comment
Know the answer?
Add Answer to:
Write code that declares an array of integer values that will represent the first five even...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT