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 16:00
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
question
Computers and Technology, 22.06.2019 19:30
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
question
Computers and Technology, 23.06.2019 03:30
In vista and windows 7, the appearance and personalization option allows you to change the
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
When is it most apprpriate for a development team to change the definition of done
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
English, 20.10.2020 03:01
question
Mathematics, 20.10.2020 03:01
question
Mathematics, 20.10.2020 03:01
Questions on the website: 13722360