Asked Nov 18, 2019
in c++
Given the following, use a range-based for loop to load the array with user input (include a prompt cout followed by cin):

const int SIZE = 5;
int numbers[SIZE];

Expert Answer

Step 1

The C++ program to enter and display the content of an integer array by using range-based for loop, cin and cout is given below:


  • Declaring the header file and the namespace.
  • The Main function is declared, and inside the main function, variables are initialized as per the requirement.
  • The const keyword is used to make the value of the SIZE variable constant.
  • Initializing the integer array of size 5.
  • Using the for loop to iterate the elements of an array.
  • Inside this loop, cin is used to prompt the user to take input.
  • Another loop is used to iterate the input elements of the numbers array.
  • Inside this loop, cout is used to display the content of the integer array.
Step 2


#include <iostream>

using namespace std;

int main()


    //using const keyword

    //to make the value of SIZE variable constant

    const int SIZE = 5;

    //integer array of size 5

    int numbers[SIZE];

    cout<<"Please enter the elements you want to fill in the array: \n";

    //using for loop to iterate the elements of array

    for (int i = 0; i < SIZE; i++)


       //prompt user to take input



Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: Write a function so that the main() code below can be replaced by the simpler code that calls functi...

A: Program:#include &lt;iostream&gt;using namespace std;double MphAndMinutesToMiles(double milesPerHour...


Q: Create a new file (in Dev C++) and save it as lab12_XYZ.cpp (replace XYZ with your initials). Create...

A: Program://Filename: lab12_XYZ.cpp#include&lt;iostream&gt; #include &lt;iomanip&gt; #include "lab12_X...


Q: Select the FSMO role that is required to be online to facilitate the addition or removal of a domain...

A: Domain Controller:Domain controller is a server computer on Microsoft servers.The purpose of domain ...


Q: Compare and contrast iOS and Android mobile operating systems. Which one is better?

A: Comparison of Android and iOS:


Q: During garbage collection, what setting controls how long deleted objects remain within the database...

A: The container object tombstone contains deleted objects from Active directory. An object that is del...


Q: (check all that apply) Under what conditions, the 3rd normal form is automatically satisfied if arel...

A: Third Normal FormThird normal form is a normal form used for normalizing a database design for reduc...


Q: Hey i need help with coding in c++  Q1 // with steps  Write a program that determines a student’s gr...

A: Approach for the program- 1)Import the essential headers.2)Define the main function.3)Declare the va...


Q: If a non-key column determines a key column, which normal form is violated?A) 1NFB) 2NFC) 3NFD) BCNF

A: BCNF:Boyce – Codd Normal Form (BCNF) is based on functional dependencies that in a relationship all ...


Q: Write down a Unix command that will change security permissions on a file named file1.txt so that th...

A: Ownership of filesUser (u): A person who creates the file. User is also known as owner of the file.G...