subject

Complete as many of the 8 questions below as you can The questions are inside of the regions below.

#include
#include

using namespace std;

#pragma region Question 1

/*
1. Write a function that meets these specifications:
Inputs:
None
Side effects:
Declare a float array with a length of 5.
Ask the user to enter a value for each element.
If any entry is not a number, notify the user and ask them to try again until they get it right
Print the values in reverse order.
Outputs:
None
*/

// Put your answer to question 1 below.

#pragma endregion

#pragma region Question 2

/*
QUESTION 2. Write a function called AskUserForCharacters() that meets these specifications:
Inputs:
Two char variables outChar1 and outChar2
Side effects:
Ask the user to enter two characters
Store the user’s first answer in outChar1
Store the user’s second answer in outChar2
Outputs:
The values of both outChar1 and outChar2 must remain modified after the function ends.
*/

// Put your answer to question 2 below.

//EXAMPLE USAGE FOR QUESTION 2:
// Your function should be compatible with the code below.
// You can uncomment this and use it for testing.

/*
int QuestionTwoExample()
{
char x;
char y;
AskUserForCharacters(x, y);
cout << x << ',' << y << endl; // this should print the two chars entered in the function
return 0;
}

*/

#pragma endregion

#pragma region Questions 3-4

/*

QUESTION 3. Write a function called GenerateArray() that meets these specifications:
Inputs:
Two numbers: n and m
Side effects:
Generate an array of numbers with a random size between n and m
Fill the array with random numbers between n and m
Outputs:
Return the generated array

Remember to test that the function outputs correctly!!

*/

// Put your answer to question 3 below.

/*
EXAMPLE USAGE FOR QUESTION 3:

// Your function should work like this.
// You can use these examples to test that it works properly.

EXAMPLE USAGE 1:
Inputs: 3, 4
Range of outputs: an array with either 3 or 4 values, each of which is either 3 or 4
Example outputs: {3, 3, 4} or {4, 3, 4, 3}

EXAMPLE USAGE 2:
Inputs: 4, 6
Range of outputs: an array with either 4, 5, or 6 values, each of which is either 4, 5, or 6
Example outputs: {4, 4, 5, 4} or {5, 4, 6, 6, 5} or {5, 4, 5, 6, 5, 6}
*/

// QUESTION 4. Demonstrate the usage of the function you wrote in question #3
// by performing these steps in a new function named TestGenerateArray()

void TestGenerateArray()
{
// A. Write a loop that does the following 10 times:

// B. Call GenerateArray(), passing 5 and 8 as arguments.

// C. Use a nested loop to print all of the contents of the generated array.

// D. Perform any necessary cleanup of the output of GenerateArray().

}

#pragma endregion

#pragma region Question 5

/*

QUESTION 5. This function has an error. Do the following:

A. Comment the function, explaining what it does.

B. Find out what the error is. Write a comment below explaining what you did to find the error.

// answer B here

C. Investigate what is causing the error. Write a comment below explaining what things you did to investigate.

// answer C here

D. Fix the error. Write a comment below explaining what the fix was.

// answer D here

*/


// Shifts the value of each element down by one, and inserts 0 at the end.
// EXAMPLE: {1, 2, 3} becomes {2, 3, 0}

void ShiftArrayElements(int array[], int size)
{
int i = 0;
while (i < size)
{
array[i] = array[i + 1];
++i;
}
array[i] = 0;
}

#pragma endregion

#pragma region Question 6

/*

QUESTION 6. This function has an error. Do the following:

A. Comment the function, explaining what it does.

B. Find out what the error is. Write a comment below explaining what you did to find the error.

// answer B here

C. Investigate what is causing the error. Write a comment below explaining what things you did to investigate.

// answer C here

D. Fix the error. Write a comment below explaining what the fix was.

// answer D here

*/


// Asks the user the length of their name, then lets them enter the name
// one character at a time. Returns the name in a char array.

char* ()
{
cout << "Enter the length of your name: ";
int length;
cin >> length;
char* pName = new char[length];
for (int i = 0; i < length; ++i)
{
cout << "Enter letter " << i << ": ";
cin >> pName[i];
}
return pName;
}

#pragma endregion

int main()
{
// Use this function for testing.

system("pause");
return 0;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Which of the statements below is true? the formatting, standard, and drawing commands are unavailable. the formatting, standard, and drawing commands have been used. the formatting, standard, and drawing toolbars are displayed. the formatting, standard, and drawing toolbars are hidden.
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
1)consider the following code snippet: #ifndef book_h#define book_hconst double max_cost = 1000.0; class book{public: book(); book(double new_cost); void set_cost(double new_cost); double get_cost() const; private: double cost; }; double calculate_terms(book bk); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_cost should be removed since header files should not contain constants.c)the definition of book should be removed since header files should not contain class definitions.d)the body of the calculate_terms function should be added to the header file.
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
You know the right answer?
Complete as many of the 8 questions below as you can The questions are inside of the regions below....
Questions
question
Physics, 24.12.2019 23:31
Questions on the website: 13722363