Question

Write a C++ program: Declares an array named numberList with 50 components of the type int....

Write a C++ program:

  1. Declares an array named numberList with 50 components of the type int.

  1. Initialize the array so that the first 25 components are equal to the square of the counter (or index) variable and the last 25 components are equal to 1, 2, 3, … , 25.

  1. Output the array so that exactly ten elements per line are printed.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream>

using namespace std;

int main()
{
   int numberList[50];

   for (int i = 0; i < 25; i++) {
      numberList[i] = i * i;
   }

   for (int i = 25; i < 50; i++) {
      numberList[i] = i - 24;
   }

   for (int i = 0; i < 50; i++) {
      cout << numberList[i] << "\t";
      if ((i + 1) % 10 == 0) {
         cout << endl;
      }
   }

   return 0;
}
Add a comment
Know the answer?
Add Answer to:
Write a C++ program: Declares an array named numberList with 50 components of the type int....
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