Computers and Technology

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;
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:20, kcameronanderso
What’s resistance in an electrical circuit ?
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, juliemiddleton05
1. web and mobile applications allow users to be actively engaged in an online activity. a true b false 2. some examples of business applications purposes are to collaborate, share files, meet virtually in real-time, and accept payments. a true b false 3. an education application would most likely do which of the following? a allow users to watch popular movies and tv shows b connect users with social and business contacts c confirm users' travel plans d teach users a new language 4. a uniform resource locator (url) is how the internet knows where to take users when an address is typed into a browser. a true b false 5. deon is required to provide the citation information for his sources. what type of information should he collect from his sources? a author name, title, date of publication, date of access, url b connections to background information c interesting facts and statistics d notes on important information
Answers: 1
image
Computers and Technology, 25.06.2019 07:50, hayleneolide
Identify an advantage of centralized processing
Answers: 1
image
Computers and Technology, 25.06.2019 15:00, ariana0517
What feature allows users to collaborate on a document by marking the edits one author makes for the other to see?
Answers: 1
Do you know the correct answer?
Complete as many of the 8 questions below as you can The questions are inside of the regions below....

Questions in other subjects:

Konu
Mathematics, 16.11.2020 04:50
Konu
History, 16.11.2020 04:50