Question

Note: Please answer the question in clear and legible steps. Nothing too advanced, this is a...

Note: Please answer the question in clear and legible steps. Nothing too advanced, this is a question for introductory C++ class. Thank you.

QUESTION:

Write C++ statements to declare the following arrays. The name of the array is up to you. Use a const int variable for the array size.

a) An array that will hold 7 integers, using an initializer list to set all values to 0.

b) An array that will hold 100 doubles.

c) An array that will hold 10 bool values.

d) An array that will hold 5 double values, using an initializer list to set the values to .25, .33, .50, .67 and .75.

e) A two-dimensional array of integers that has 3 rows and 6 columns.

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

a) An array that will hold 7 integers, using an initializer list to set all values to 0.

int arr1[7] = {0};

b) An array that will hold 100 doubles.

double arr2[100];

c) An array that will hold 10 bool values.

bool arr3[10];

d) An array that will hold 5 double values, using an initializer list to set the values to .25, .33, .50, .67 and .75.

double arr4[5] = {0.25, 0.33, 0.50, 0.67, 0.75};

e) A two-dimensional array of integers that has 3 rows and 6 columns.

int arr[3][6];

\color{red}Please\; upvote\;the \;solution \;if \;it \;helped.\;Thanks!?

Add a comment
Know the answer?
Add Answer to:
Note: Please answer the question in clear and legible steps. Nothing too advanced, this is a...
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
  • How to initialize a dynamic two-dimensional array with values? (C++) Here's my problem... # include using...

    How to initialize a dynamic two-dimensional array with values? (C++) Here's my problem... # include using namespace std; int main() {    // Q#5 - dynamic 2d arrays, indexing via subscript operator, pointer arithmetic    // tic tac toe board is an array of int pointers    // each int pointer in the board points to a row    // declare a pointer to an array of int pointers (i.e. a pointer to a pointer of type int)    const...

  • Please answer in C++, and Please consider ALL parts of the question, especially where it asks the...

    Please answer in C++, and Please consider ALL parts of the question, especially where it asks the user for V. So there should be a "cin >> V" somewhere. The last guy did not answer it correctly so please make sure you do! Thank You!! Question 1 Write the following two functions. The first function accepts as input a two-dimensional array of integers. It returns two results: the sum of the elements of the array and the average The second...

  • Write a program that works with two arrays of the same size that are related to...

    Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be:  from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array...

  • /* * Program5 for Arrays * * This program illustrates how to use a sequential search...

    /* * Program5 for Arrays * * This program illustrates how to use a sequential search to * find the position of the first apparance of a number in an array * * TODO#6: change the name to your name and date to the current date * * Created by Li Ma, April 17 2019 */ #include <iostream> using namespace std; //global constant const int ARRAY_SIZE = 10; //TODO#5: provide the function prototype for the function sequentialSearch int main() {...

  • I need help as quick as possible, thanks beforehand. Please provide the test output The Lo...

    I need help as quick as possible, thanks beforehand. Please provide the test output The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. 35 The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 - 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: 15 4 92 15 - 81 + 15 15 15...

  • Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of...

    Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Description The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. s is shown below: Write a program that...

  • help with C++ code The aim of this is to practice writing template classes. You must...

    help with C++ code The aim of this is to practice writing template classes. You must use SafeArray template class and implement a SafeMatrix template class that will allow you to work with two dimensional arrays of any type. The boundaries are checked. You must be able to create instances of SafeMatrix template class like, SafeMatrix<int> m(2,3); The above statement will create a 2 by 3 dimensional array of integers. You must be able to access and set values using...

  • Please help with this coding 1.You need to dynamically allocate memory to read into a number...

    Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...

  • Unit 7 Worksheet #2                                        &

    Unit 7 Worksheet #2                                            Name: Declare and initialize a 3 x 3 two-‐dimensional array that has the numbers 1-‐9 in it using an initializer list. On the array below: int[][] values = new int[4][10]; for(int r = 0; r < values.length; r++) { for(int c = 0; c < values[r].length; c++) { values[r][c] = (int)(Math.random()*51 + 50); } } write the code to count and print the number of elements that are greater than 75. What is the syntax...

  • * This program illustrates how to use a sequential search to find the position of the...

    * This program illustrates how to use a sequential search to find the position of the first apparance of a number in an array TODO#6: change the name to your name and date to the current date * * Created by John Doe, April 17 2019 */ #include using namespace std; //global constant const int ARRAY_SIZE = 10; //TODO#5: provide the function prototype for the function sequentialSearch int main() { //TODO#1: declare an integer array named intList with size of...

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