Question

For questions 1 and 2 declare the array size as name constant first then use it...

For questions 1 and 2 declare the array size as name constant first then use it to declare the array

1. Declare an array named scores of type double and size 30.

2. Declare an array named names of string objects and size 15

3. Given the following array definition:

int values[] = {2, 5, 8, 11};

What does each of the following display?

  1. cout << values[1];        

B) cout << value[3]+values[0];  

  1. Define a three element array named letters, initialize it with characters ‘E’, ‘G’ and ‘P’. Then write C++ statement to display the 3rd element of the array.

Homework Answers

Answer #1

1.

const int size = 30;
double scores[size];

2.

const int size = 15;
string names[size];

3.

The given array is:

int values[] = {2, 5, 8, 11};

A.

The statement as given below:

cout << values[1];

OUTPUT:

5

B.

The statement as given below:

cout << value[3]+values[0];

OUTPUT:

13

The three element array declaration is given below:

//character array declaration and initialization
char letters[3] = {'E', 'G', 'P'};

//display the third element
cout<<letters[2];

Know the answer?
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
Similar Questions
In this lab, we want to get some practice with pointers -- specifically, the basic syntax...
In this lab, we want to get some practice with pointers -- specifically, the basic syntax of declaring them, storing memory addresses into them, dereferencing them, and seeing how they work with pointer arithmetic in the context of built-in, C-style arrays. Unless specified otherwise, you can use any valid variable names you wish. The requirements for this program are as follows: Part A Declare a pointer-to-int, initialized to nullptr. Declare an int variable, initialized to some value of your choice....
Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1,...
Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9]) add it with 2nd item...
C++ //StudentDataStructure.txt //Student records are stored in a parallel-array Data Structure. Here is the code to...
C++ //StudentDataStructure.txt //Student records are stored in a parallel-array Data Structure. Here is the code to generate and populate Parallel-Array Data Structure: const int NG = 4; //Number of Grades string names[] = {"Amy Adams", "Bob Barr", "Carla Carr", "Dan Dobbs", "Elena Evans" }; int exams[][NG]= { {98,87,93,88}, {78,86,82,91}, {66,71,85,94}, {72,63,77,69}, {91,83,76,60} };    --------------------------------------------------------------------------------- 1 A) Create and Populate a Parallel-Array Data Structure using the code described in "StudentDataStructure.txt". B) Define a Record Data Structure for student records. It...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
Write a template-based class that implements a template-based implementation of Homework 3 that allows for any...
Write a template-based class that implements a template-based implementation of Homework 3 that allows for any type dynamic arrays (replace string by the template in all instances below). • The class should have: – A private member variable called dynamicArray that references a dynamic array of type string. – A private member variable called size that holds the number of entries in the array. – A default constructor that sets the dynamic array to NULL and sets size to 0....
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write()...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write() and read() functions with binary                                                        data, where the data is not char type.              (Typecasting is required) Fill in the blanks, then enter the code and run the program. Note:   The data is int type, so typecasting is            required in the write() and read() functions. #include <iostream> #include <fstream> using namespace std; int main() {    const int SIZE = 10;   ...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
1) Develop a C++ function that determines the average value of an array of type double...
1) Develop a C++ function that determines the average value of an array of type double elements double GetAverage(double array[], int size) The function should accept as input an array of double values The function should accept as input the number of elements in the array of double values The function should return a double value which is the array's average value 2) Develop a C++ function that determines the variance of an array of type double elements double GetVariance(double...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT