Homework Answers

Math 51397 50414
Physics 44335 44333
Chemistry 40988 40988
Economics 30646 30644
Programming & Computer Science 26878 26876
English 10084 10084
Biology 8111 8109
Management 6239 6239
Engineering 6056 6056
History 3490 3489
Psychology 2129 2129
Sociology 1858 1858
Geography 1574 1574
Marketing 1443 1443
Philosophy 1001 1001
Political Science 892 891
Law 876 876
French 438 438
Other 199 199

Questions: 238 634

Answers by our Experts: 237 641

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

This is similar to the exercise we did in class but with two changes: (1) Use doubles instead of ints; (2) The user will be providing the numbers. Just like the class exercise, output the sum, average, highest, and lowest of the user's numbers. 

 

Output:

This program will ask you to enter 5 numbers with decimal places.

It will then show you the total, average, largest number, and smallest number.

Enter a number:   [user types: 5.2]


Enter a number:   [user types: 9.8]


Enter a number:   [user types: 2.5]


Enter a number:   [user types: 17.5]


Enter a number:   [user types: 7.5]


Total: 42.5

Average: 8.5

Lowest: 2.5

Highest: 17.5


Let's start with an easy one. Create an array that stores 4 integers. Ask the user to enter any 4 numbers, one by one. Finally, output those numbers separated by three spaces.

 

Output:


This program will ask you to enter 4 numbers. It will then confirm your entries.

Enter a number:  [user types: 1]


Enter a number:  [user types: 2]


Enter a number:  [user types: 3]


Enter a number:  [user types: 4]


Your numbers: 1  2  3  4


All values in an array must be of the same data type.


A: True.

B: False.


The C++ compiler will return an error message if you use an array subscript that is beyond the boundaries of the array.


A: True.

B: False.


Observe the following code:

 

const int SIZE = 3;

int nums[SIZE] = {1, 2, 3};

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

  std::cout << nums[i];

}

 

What is wrong with this code?


A: You cannot use constants with array definitions.

B: The initialization list exceeds the size of the array.

C: Should be i = 1 because you need to start with the first array element.

D: Should be I < SIZE so that you don't access an array element that doesn't exist.


Observe the following code:

 

int nums[3] = {1, 2, 3};

std::cout << nums;

 

What will be output to the screen?


A: 1.

B: 3.

C: 123.

D: A memory address.


Observe the following code:

 

std::cout << grades[1];

 

Which grade will be output to the screen?


A: The first grade.

B: The second grade.

C: All grades in the array.

D: Invalid code / Error.


Observe the following code:

 

int grades[5] = {0};

std::cout << grades[1];

 

What is the [1] part?


A: The Initialization List.

B: A Subscript.

C: The Size Declarator.

D: A Value.


Observe the following code:

 

int grades[5] = {0};

std::cout << grades[1];

 

What is the {0} part?


A: The Initialization List.

B: A Subscript.

C: The Size Declarator.

D: None of the above.


LATEST TUTORIALS
APPROVED BY CLIENTS